Part Number Hot Search : 
AC2078 KSZ8999 FDC602P HYS64 D0Z14G16 NTD72H LM8363 X9421
Product Description
Full Text Search
 

To Download HT82B42R Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  i/o mcu with usb interface HT82B42R/HT82B42Re revision: v.1.00 date: october 27, 2011
rev. 1.00 2 october 27, 2011 rev. 1.00 3 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface table of contents eates eneal eston eleton table lo aa HT82B42R .............................................................................................................................. 6 HT82B42Re ............................................................................................................................ 7 pin assignment ................................................................................................ 8 pin description ................................................................................................ 9 absolute maximum ratings ........................................................................... 11 d.c. characteristics ........................................................................................ 11 eeprom memory d.c. characteristics ....................................................... 12 a.c. characteristics ....................................................................................... 12 system architecture ...................................................................................... 13 clocking and pipelining ......................................................................................................... 13 program counter ................................................................................................................... 13 stack ..................................................................................................................................... 15 arithmetic and logic unit C alu ........................................................................................... 15 program memory ........................................................................................... 16 structure ................................................................................................................................ 16 special vectors ..................................................................................................................... 17 look-up table ........................................................................................................................ 18 table program example ........................................................................................................ 19 data memory .................................................................................................. 20 structure ................................................................................................................................ 20 general purpose data memory .................................................................... 20 special function registers ........................................................................... 21 indirect addressing register C iar0, iar1 ........................................................................... 21 memory pointer C mp0, mp1 ................................................................................................ 22 accumulator C acc ............................................................................................................... 22 program counter low register C pcl .................................................................................. 22 look-up table registers C tblp, tblh, tbhp .................................................................... 23 status register C status .................................................................................................... 23 bank pointer C bp ................................................................................................................. 24 input/output ports ......................................................................................... 25 pull-high resistors ................................................................................................................ 25 port a cmos/nmos/pmos structure .................................................................................. 25 port a vdd/v33o option structure ....................................................................................... 25 port pin wake-up .................................................................................................................. 25 i/o port control registers ..................................................................................................... 26
rev. 1.00 2 october 27, 2011 rev. 1.00 3 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface pin-shared functions ............................................................................................................ 26 programming considerations ................................................................................................ 28 timer/event counters ................................................................................... 28 confguring the timer/event counter input clock source .................................................... 29 timer register C tmr0, tmr1l/tmr1h .............................................................................. 29 timer control register C tmr0c/tmr1c ............................................................................ 30 confguring the timer mode .................................................................................................. 32 confguring the event counter mode .................................................................................... 32 confguring the pulse width measurement mode ................................................................. 33 i/o interfacing ........................................................................................................................ 34 programming considerations ................................................................................................ 34 timer program example ....................................................................................................... 35 interrupts ........................................................................................................ 36 interrupt registers ................................................................................................................. 36 interrupt operation ................................................................................................................ 37 interrupt priority ..................................................................................................................... 38 timer/event counter interrupt ............................................................................................... 38 programming considerations ................................................................................................ 38 usb interrupt ........................................................................................................................ 39 serial interface interrupt ........................................................................................................ 39 reset and initialisation .................................................................................. 39 reset functions .................................................................................................................... 40 reset initial conditions ......................................................................................................... 42 oscillator ........................................................................................................ 44 watchdog timer oscillator .................................................................................................... 44 power down mode and wake-up .................................................................. 44 power down mode ................................................................................................................ 44 entering the power down mode ........................................................................................... 44 standby current considerations ........................................................................................... 45 wake-up ................................................................................................................................ 45 watchdog timer ............................................................................................. 46 usb interface ................................................................................................. 47 suspend wake-up and remote wake-up ............................................................................ 47 to confgure as ps2 device ................................................................................................. 48 usb control registers .......................................................................................................... 48 stall and pipe, pipe_ctrl, endpt_en registers ........................................................... 51 serial interface C spi .................................................................................... 57 spi interface operation ......................................................................................................... 57 spi registers ........................................................................................................................ 58 spi communication .............................................................................................................. 61 spi bus enable/disable ........................................................................................................ 63 spi operation ........................................................................................................................ 64 error detection ...................................................................................................................... 65
rev. 1.00 4 october 27, 2011 rev. 1.00 5 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface confguration options ................................................................................... 66 application circuit ......................................................................................... 66 instruction set ................................................................................................ 67 introduction ........................................................................................................................... 67 instruction timing .................................................................................................................. 67 moving and transferring data ............................................................................................... 67 arithmetic operations ............................................................................................................ 67 logical and rotate operations .............................................................................................. 68 branches and control transfer ............................................................................................. 68 bit operations ....................................................................................................................... 68 table read operations ......................................................................................................... 68 other operations ................................................................................................................... 68 instruction set summary ....................................................................................................... 69 instruction defnition ..................................................................................... 71 package information ..................................................................................... 81 16-pin nsop (150mil) outline dimensions ........................................................................... 81 20-pin ssop (150mil) outline dimensions ........................................................................... 82 saw type 20-pin (4mm4mm) qfn outline dimensions .................................................... 83 reel dimensions ................................................................................................................... 84 carrier tape dimensions ....................................................................................................... 85
rev. 1.00 4 october 27, 2011 rev. 1.00 5 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface features ? operating voltage: f sys =6m/12mhz: 3.3v~5.5v ? fully integrated 6mhz or 12mhz oscillator ? 409615 program memory ? 1608 data memory ram ? eeprom memory: 1288 (for HT82B42Re only) ? usb 2.0 low speed function ? ps2 and usb modes supported ? 3 endpoints supported C endpoint 0 included ? integrated 1.5k resistor between v33o and udn pins for usb applications ? internal regulator with 3.3v output ? 8-level subroutine nesting ? 15 bidirectional i/o lines (max.) ? 8-bit programmable timer/event counter with overfow interrupt ? 16-bit programmable timer/event counter with overfow interrupt ? watchdog timer ? serial spi interface ? all i/o pins have wake-up functions ? power-down function and wake-up feature reduce power consumption ? up to 0.33s instruction cycle with 12mhz system clock at v dd =5v ? bit manipulation instruction ? 15-bit table read instruction ? 63 powerful instructions ? all instructions in one or two machine cycles ? low voltage reset function ? 16-pin nsop, 20-pin ssop and 20-pin qfn packages general description the HT82B42R is 8-bit high performance, risc architecture microcontroller devices specifcally designed for multiple i/o control product applications. in addition, the HT82B42Re is embedded with an eeprom device. the advantages of low power consumption, i/o flexibility, timer functions, integrated usb interface, serial spi interface, power down and wake-up functions, watchdog timer etc., make the devices extremely suitable for use in computer peripheral product applications as well as many other applications such as industrial control, consumer products, subsystem controllers, etc.. eeprom memory is incorporated into the HT82B42Re, which is useful for applications that require an area of non-volatile memory, perhaps to store information such as calibration parameters, part numbers etc.. most features are common to the HT82B42R, however, they differ in the provision of an eeprom.
rev. 1.00 6 october 27, 2011 rev. 1.00 7 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface selection table most features are common to all devices, the main feature distinguishing them is eeprom. the following table summarizes the main features of each device. part no. vdd program memory data memory data eeprom i/o timer end- points hirc (mhz) ldo 70ma i/o vdd option spi stack package 8-bit 16-bit HT82B42R 3.3v~ 5.5v 4k15 1608 15 1 1 3 6/12 8 16nsop 20ssop 20qfn HT82B42Re 3.3v~ 5.5v 4k15 1608 128x8 13 1 1 3 6/12 8 20qfn block diagram HT82B42R               
          
          
   
      
 
    ?              
   ? ? ?        ? ?? ?   - ?? 

   

 
rev. 1.00 6 october 27, 2011 rev. 1.00 7 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface the following block diagrams illustrate the dual-chip structure of the devices, where an individual mcu with eeprom devices are combined into a single package. ht 2201 vddp vssp ht 82b 42r sda scl usb pins res tmr pins spi i / o ports vdd vss vdd vss pe0 pe 1 HT82B42Re
rev. 1.00 8 october 27, 2011 rev. 1.00 9 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface pin assignment vdd v33o udn / data udp / clk pe0 pa 7 / tmr 1 pa 6 / tmr 0 pa 5 pa 4 / scs pa 3 / sck 16 15 14 13 12 11 1 2 3 4 5 6 7 8 9 10 pe1 vss pe2 / res pa 0 pa 1 / sdi pa 2 / sdo ht 82b 42 r 16 nsop -a pb 2 pb 3 vdd v33o udn / data udp / clk vss pb 1 pb 0 pa7 / tmr 1 pa6 / tmr 0 pa5 pa4 / scs pa3 / sck 20 19 18 17 16 15 14 13 12 11 1 2 3 4 5 6 7 8 9 10 pe2 / res pe 0 pe 1 pa0 pa1 / sdi pa2 / sdo 6 7 8 9 10 16 17 18 19 20 1 2 3 4 5 15 14 13 12 11 pb3 pe2 / res vd d v33 o udn / data udp / clk vss pa 5 pe1 pa0 pa1 / sd i pa6 / t mr 0 pa2 / sd o pe0 pa 3 / sck pa4 / sc s pa7 / t mr 1 pb0 pb1 pb2 ht 82b 42 r 20 ssop -a ht 82 b 42 r 20 qfn -a 6 7 8 9 10 16 17 18 19 20 1 2 3 4 5 15 14 13 12 11 pb3 pe2 / res vd d v33 o udn / data udp / clk vss pa5 pe1 / sc l pa0 pa1 / sd i pa6 / t mr 0 pa2 / sd o pe0 / sd a pa3 / sck pa 4 / sc s pa7 / t mr 1 pb0 pb1 pb2 ht 82 b 42 re 20 qfn -a
rev. 1.00 8 october 27, 2011 rev. 1.00 9 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface pin description the pins on this device can be referenced by their port name, e.g. pa.0, pa.1 etc., which refer to the digital i/o function of the pins. however these port pins are also shared with other function such as the timers, serial port pins etc.. the function of each pin is listed in the following table, however the details behind how each pin is confgured is contained in other sections of the datasheet. HT82B42R pin name function opt i/t o/t description pa0 pa0 co st nmos /cmos /pmos *hqhudosxusrvh,2&rqjxudwlrqrswlrqhqdeohgsxooxszdnhxs vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. pa1/sdi pa1 co st nmos /cmos /pmos *hqhudosxusrvh,2&rqjxudwlrqrswlrqhqdeohgsxooxszdnhxs vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. sdi st spi data input pa2/sdo pa2 co st nmos /cmos /pmos *hqhudosxusrvh,2&rqjxudwlrqrswlrqhqdeohgsxooxszdnhxs vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. sdo cmos spi data output pa3/sck pa3 co st nmos /cmos /pmos *hqhudosxusrvh,2&rqjxudwlrqrswlrqhqdeohgsxooxszdnhxs vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. sck st cmos spi serial clock pa4/ scs pa4 co st nmos /cmos /pmos *hqhudosxusrvh,2&rqjxudwlrqrswlrqhqdeohgsxooxszdnhxs vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. scs st spi slave select pa5 pa5 co st nmos /cmos /pmos *hqhudosxusrvh,2&rqjxudwlrqrswlrqhqdeohgsxooxszdnhxs output structure and vdd or 3.3v voltage output. the output structure can be selected as cmos, nmos or pmos. pa6/tmr0 pa6 co st nmos /cmos /pmos *hqhudosxusrvh,2&rqjxudwlrqrswlrqhqdeohgsxooxszdnhxs output structure and vdd or 3.3v voltage output. the output structure can be selected as cmos, nmos or pmos. tmr0 st timer 0 external input pa7/tmr1 pa7 co st nmos /cmos /pmos *hqhudosxusrvh,2&rqjxudwlrqrswlrqhqdeohgsxooxszdnhxs output structure and vdd or 3.3v voltage output. the output structure can be selected as cmos, nmos or pmos. tmr1 st timer 1 external input pb0~pb3 pb0~pb3 co st cmos *hqhudosxusrvh,2&rqjxudwlrqrswlrqhqdeohgsxooxsdqgzdnhxs pe0~pe1 pe0~pe1 co st cmos *hqhudosxusrvh,2&rqjxudwlrqrswlrqhqdeohgsxooxsdqgzdnhxs pe2/ res pe2 co st nmos *hqhudosxusrvh,2&rqjxudwlrqrswlrqzdnhxs res co st reset input udn/data udn st cmos usb d- line data st nmos ps2 data line udp/clk udp st cmos usb d+ line clk st nmos ps2 clk line vdd vdd pwr power supply vss vss pwr ground v33o v33o pwr 3.3v regulator output
rev. 1.00 10 october 27, 2011 rev. 1.00 11 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface HT82B42Re pin name function opt i/t o/t description pa0 pa0 co st nmos /cmos /pmos general purpose i/o. confguration option enabled pull-up, wake-up, vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. pa1/sdi pa1 co st nmos /cmos /pmos general purpose i/o. confguration option enabled pull-up, wake-up, vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. sdi D st D spi data input pa2/sdo pa2 co st nmos /cmos /pmos general purpose i/o. confguration option enabled pull-up, wake-up, vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. sdo D D cmos spi data output pa3/sck pa3 co st nmos /cmos /pmos general purpose i/o. confguration option enabled pull-up, wake-up, vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. sck D st cmos spi serial clock pa4/ scs pa4 co st nmos /cmos /pmos general purpose i/o. confguration option enabled pull-up, wake-up, vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. scs D st D spi slave select pa5 pa5 co st nmos /cmos /pmos general purpose i/o. confguration option enabled pull-up, wake-up, vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. pa6/tmr0 pa6 co st nmos /cmos /pmos general purpose i/o. confguration option enabled pull-up, wake-up, vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. tmr0 D st D timer 0 external input pa7/tmr1 pa7 co st nmos /cmos /pmos general purpose i/o. confguration option enabled pull-up, wake-up, vdd or 3.3v voltage output and output structure, which can be selected as cmos, nmos or pmos. tmr1 D st D timer 1 external input pb0~pb3 pb0~pb3 co st cmos general purpose i/o. confguration option enabled pull-up and wake-up. pe0/sda pe0 co st cmos general purpose i/o. confguration option enabled pull-up and wake-up. sda D D D internal serial data input/output signal pe1/scl pe1 co st cmos general purpose i/o. confguration option enabled pull-up and wake-up. scl D D D serial clock input signal pe2/ res pe2 co st nmos general purpose i/o. confguration option wake-up. res co st D reset input udn/data udn D st cmos usb d- line data D st nmos ps2 data line udp/clk udp D st cmos usb d+ line clk D st nmos ps2 clk line vdd vdd D pwr D power supply vss vss D pwr D ground v33o v33o D D pwr 3.3v regulator output 1rwh ,7,qsxwwsh 272xwsxwwsh 237 2swlrqdoefrqjxudwlrqrswlrq&2ruuhjlvwhurswlrq 3:53rzhu &2&rqjxudwlrqrswlrq 67 6fkplww 7uljjhu lqsxw &026&026rxwsxw :khuh ghylfhv h[lvw lq pruh wkdq rqh sdfndjh wsh wkh wdeoh uhhfwv wkh vlwxdwlrq iru wkh sdfndjh zlwk wkh odujhvw qxpeh urislqv)ruwklvuhdvrqqrwdooslqvghvfulehglqwkhwdeohpdh[lvwrqdoosdfndjhwshv
rev. 1.00 10 october 27, 2011 rev. 1.00 11 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface absolute maximum ratings supply voltage ................................................................................................ v ss ?0.3v to v ss +6.0v input voltage .................................................................................................. v ss ? 0.3v to v dd +0.3v storage temperature ................................................................................................... -50 c to 125c operating temperature ................................................................................................. -40 c to 85 c i oh total .................................................................................................................................. -100ma i ol total ................................................................................................................................... 150ma total power dissipation ........................................................................................................ 500mw note: these are stress ratings only. stresses exceeding the range specified under "absolute maximum ratings" may cause substantial damage to the device. functional operation of this device at other conditions beyond those listed in the specifcation is not implied and prolonged exposure to extreme conditions may affect device reliability. d.c. characteristics ta=25c symbol parameter test conditions min. typ. max. unit v dd conditions v dd operating v oltage (integrated oscillator) f sys =6mhz or 12mhz 3.3 5.5 v i dd operating c urrent 5 v no load, f sys =6mhz 6.5 12 ma no load, f sys =12mhz 7.5 16 ma i stb standby current 5 v no load, system usb suspend, set clk_adj [22h] "*" 400 standby current (wdt enabled) no load, system h alt, input/output mode, set susp2 & clk_adj [22h] 15 v il input low voltage for pa 5 v where v ddio =v dd or v33o by option for port a 0 0.2v ddio v input low voltage for pb, pe 0 0.2v dd v input low voltage for res pin 0 0.4v dd v v ih input high voltage for pa 5 v where v ddio =v dd or v33o by option for port a 0.8v ddio 5 v input high voltage for pb, pe 0.8v dd 5 v input high voltage for res pin 0.9v dd v dd v v lv r low v oltage reset 5 v 2.0 2.6 3.2 v v v33o 3.3v regulator output for usb sie 5v i v33o =70ma 3.0 3.3 3.6 v i oh output source current for i/o pin pa, pb, pe0~1 5 v v oh =3.4v -2 -4 ma i ol1 output sink current for i/o pin pa, pb, pe0~1 5 v v ol =0.4v 2 4 ma i ol2 output sink current for pe2 5 v v ol =0.1v dd 2 3 ma r ph pull-high resistance for clk, data 5 v 4.7 n pull-high resistance for pa, pb, pe0~1 20 50 70 n note: "*" include 15k loading on the udp, udn lines at the host terminal.
rev. 1.00 12 october 27, 2011 rev. 1.00 13 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface eeprom memory d.c. characteristics ta=40c~85c symbol parameter test conditions min. typ. max. unit v ddp condition v cc operating voltage 2.2 5.5 v i cc1 * operating current 5v read at 100khz 2 ma i cc2 * operating current 5v write at 100khz 5 ma i stb1 * standby current 5v v in =0 or v ddp 4 a i stb2 * standby current 2.4v v in =0 or v ddp 3 a v il input low voltage -1 0.3v ddp v v ih input high voltage 0.7v ddp v ddp +0.5 v v ol output low voltage 2.4v i ol =2.1ma 0.4 v i li input leakage current 5v v in =0 or v ddp 1 a i lo output leakage current 5v v out =0 or v ddp 1 a note * the operating current i cc1 and i cc2 listed here are the additional currents consumed when the eepom memory operates in ead operation and write operation respectively. if the eepom is operating, the i cc1 or i cc2 should be added to calculated the relevant operating current of the device for defferent conditions. to calculate the standby current for the whole device, the standby current shown above should also be taken into account. a.c. characteristics ta=25c symbol parameter test conditions min. typ. max. unit v dd conditions f rcsys rc clock with 8-bit prescaler register 5v 32 khz t wdt watchdog time-out period (system clock) 1024 1/f rcsys t usb udp, udn rising & falling time 75 300 ns t ost oscillation start-up timer period 1024 t sys t oscsetup crystal setup 5 ms f ino125v internal oscillator frequency for 12mhz 4.0v~5.5 v 10.80 12.00 13.20 mhz f ino123v internal oscillator frequency for 12mhz 3.0v~4.0 v 10.56 12.00 13.44 mhz f inousb internal oscillator frequency with usb mode 4.2v~5.5 v 11.82 12.00 12.18 mhz 1rwhw sys =1/f sys hshl +t 26 +t 26hs lph l1po0h i 66 6 lph lh0h i 66 6 26 +t 26 hs lpph i shllilpyohhh lp 0+
rev. 1.00 12 october 27, 2011 rev. 1.00 13 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface system architecture a key factor in the high-performance features of the holtek range of microcontrollers is attributed to the internal system architecture. the range of devices take advantage of the usual features found within risc microcontrollers providing increased speed of operation and enhanced performance. the pipelining scheme is implemented in such a way that instruction fetching and instruction execution are overlapped, hence instructions are effectively executed in one cycle, with the exception of branch or call instructions. an 8-bit wide alu is used in practically all operations of the instruction set. it carries out arithmetic operations, logic operations, rotation, increment, decrement, branch decisions, etc.. the internal data path is simplifed by moving data through the accumulator and the alu. certain internal registers are implemented in the data memory and can be directly or indirectly addressed. the simple addressing methods of these registers along with additional architectural features ensure that a minimum of external components is required to provide a functional i/o and a/d control system with maximum reliability and fexibility. clocking and pipelining the system clock is derived from an internal oscillator and is subdivided into four internally generated non-overlapping clocks, t1~t4. the program counter is incremented at the beginning of the t1 clock during which time a new instruction is fetched. the remaining t2~t4 clocks carry out the decoding and execution functions. in this way, one t1~t4 clock cycle forms one instruction cycle. although the fetching and execution of instructions takes place in consecutive instruction cycles, the pipelining structure of the microcontroller ensures that instructions are effectively executed in one instruction cycle. the exception to this are instructions where the contents of the program counter are changed, such as subroutine calls or jumps, in which case the instruction will take one more instruction cycle to execute. for instructions involving branches, such as jump or call instructions, two machine cycles are required to complete instruction execution. an extra cycle is required as the program takes one cycle to frst obtain the actual jump or call address and then another cycle to actually execute the branch. the requirement for this extra cycle should be taken into account by programmers in timing sensitive applications. program counter during program execution, the program counter is used to keep track of the address of the next instruction to be executed. it is automatically incremented by one each time an instruction is executed except for instructions, such as "jmp" or "call" that demand a jump to a non-consecutive program memory address. it must be noted that only the lower 8 bits, known as the program counter low register, are directly addressable by user.
rev. 1.00 14 october 27, 2011 rev. 1.00 15 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface                                                        
                       ?                     ?        ?  ?   ? system clocking and pipelining                             
      ? ? ? ?     ?  ? ? ?   ?                                  ? instruction fetching when executing instructions requiring jumps to non-consecutive addresses such as a jump instruction, a subroutine call, interrupt or reset, etc., the microcontroller manages program control by loading the required address into the program counter. for conditional skip instructions, once the condition has been met, the next instruction, which has already been fetched during the present instruction execution, is discarded and a dummy cycle takes its place while the correct instruction is obtained. the lower byte of the program counter, known as the program counter low register or pcl, is available for program control and is a readable and writeable register. by transferring data directly into this register, a short program jump can be executed directly, however, as only this low byte is available for manipulation, the jumps are limited to the present page of memory, that is 256 locations. when such program jumps are executed it should also be noted that a dummy cycle will be inserted. the lower byte of the program counter is fully accessible under program control. manipulating the pcl might cause program branching, so an extra cycle is needed to pre-fetch. further information on the pcl register can be found in the special function register section.
rev. 1.00 14 october 27, 2011 rev. 1.00 15 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface stack this is a special part of the memory which is used to save the contents of the program counter only. the stack has 8 levels and is neither part of the data nor part of the program space, and is neither readable nor writeable. the activated level is indexed by the stack pointer, sp, and is neither readable nor writeable. at a subroutine call or interrupt acknowledge signal, the contents of the program counter are pushed onto the stack. at the end of a subroutine or an interrupt routine, signaled by a return instruction, ret or reti, the program counter is restored to its previous value from the stack. after a device reset, the stack pointer will point to the top of the stack. if the stack is full and an enabled interrupt takes place, the interrupt request fag will be recorded but the acknowledge signal will be inhibited. when the stack pointer is decremented, by ret or reti, the interrupt will be serviced. this feature prevents stack overfow allowing the programmer to use the structure more easily. however, when the stack is full, a call subroutine instruction can still be executed which will result in a stack overfow. precautions should be taken to avoid such cases which might cause unpredictable program branching.                                
                            arithmetic and logic unit C alu the arithmetic-logic unit or alu is a critical area of the microcontroller that carries out arithmetic and logic operations of the instruction set. connected to the main microcontroller data bus, the alu receives related instruction codes and performs the required arithmetic or logical operations after which the result will be placed in the specifed register. as these alu calculation or operations may result in carry, borrow or other status changes, the status register will be correspondingly updated to refect these changes. the alu supports the following functions: ? arithmetic operations: add, addm, adc, adcm, sub, subm, sbc, sbcm, daa ? logic operations: and, or, xor, andm, orm, xorm, cpl, cpla ? rotation: rra, rr, rrca, rrc, rla, rl, rlca, rlc ? increment and decrement: inca, inc, deca, dec ? branch decision: jmp, sz, sza, snz, siz, sdz, siza, sdza, call, ret, reti
rev. 1.00 16 october 27, 2011 rev. 1.00 17 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface mode program counter bits *11~*8 *7 *6 *5 *4 *3 *2 *1 *0 initial reset 0 0 0 0 0 0 0 0 0 usb interrupt 0 0 0 0 0 0 1 0 0 timer/event 0 counter overfow 0 0 0 0 0 1 0 0 0 timer/event 1 counter overfow 0 0 0 0 0 1 1 0 0 spi interrupt 0 0 0 0 1 0 0 0 0 skip program counter+2 loading pcl @11~@8 @7 @6 @5 @4 @3 @2 @1 @0 jump, call branch #11~#8 #7 #6 #5 #4 #3 #2 #1 #0 return (ret, reti) s11~s8 s7 s6 s5 s4 s3 s2 s1 s0 program counter 1rwh 3&a3&&xuuhqw3urjudp&rxqwhu elwv a3&/ elwv a ,qvwuxfwlrqfrghdgguhvv elwv 6a66wdfn uhjlvwhuelwv program memory 7kh 3urjudp 0hpru lv wkh orfdwlrq zkhuh wkh xvhu frgh ru surjudp lv vwruhg 7kh 7575( duh 2qh7lph 3urjudppdeoh 273 phpru wsh ghlfhv zkhuh xvhuv fdq surjudp wkhlu dssolfdwlrq frgh lqwr wkh ghlfhv xvlqj wkh dssursuldwh surjudpplqj wrrov 273 ghlfhv riihu xvhuv wkh ioh[lelolw wr iuhho ghhors wkhlu dssolfdwlrqv zklfk pd eh xvhixo gxulqj ghexj ru iru surgxfwv uhtxlulqj iuhtxhqw xsjudghv ru surjudp fkdqjhv 273 ghlfhv duh dovr dssolfdeohiruxvhlqdssolfdwlrqvwkdwuhtxluhorzruphglxproxphsurgxfwlrquxqv structure 7kh 3urjudp 0hpru kdv d fdsdflw ri . e elwv 7kh 3urjudp 0hpru lv dgguhvvhg e wkh 3urjudp &rxqwhu dqg dovr frqwdlqv gdwd wdeoh lqirupdwlrq dqg lqwhuuxsw hqwulhv 7deoh gdwd zklfk fdq eh vhwxs lq dq orfdwlrq zlwklq wkh 3urjudp 0hpru lv dgguhvvhg e vhsdudwh wdeoh srlqwhu uhjlvwhuv                
                                 
                    ?          program memory structure
rev. 1.00 16 october 27, 2011 rev. 1.00 17 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface special vectors within the program memory, certain locations are reserved for special usage such as reset and interrupts. ? location 000h this area is reserved for program initialization. after chip reset, the program always begins execution at location 000h. ? location 004h this area is reserved for the usb interrupt service program. if the usb interrupt is activated, the interrupt is enabled and the stack is not full, the program jumps to this location and begins execution. ? location 008h this area is reserved for the timer/event counter 0 interrupt service program. if a timer interrupt results from a timer/event counter 0 overfow, and if the interrupt is enabled and the stack is not full, the program jumps to this location and begins execution. ? location 00ch this area is reserved for the timer/event counter 1 interrupt service program. if a timer interrupt results from a timer/event counter 1 overfow, and the interrupt is enabled and the stack is not full, the program jumps to this location and begins execution. ? location 010h this area is reserved for the spi interrupt service program. if a spi interrupt results from a byte of data has been transmitted or received by the spi interface, and the interrupt is enabled and the stack is not full, the program jumps to this location and begins execution. ? table location any location in the program memory can be used as look-up tables. there are three methods to read the program memory data using two table read instructions: "tabrdc" and "tabrdl", transfer the contents of the lower-order byte to the specifed data memory, and the higher-order byte to tblh (08h). the three methods are shown as follows: using the instruction "tabrdc [m]" for the current program memory page, where one page= 256words, where the table location is defned by tblp in the current page. this is where the confguration option has disabled the tbhp register. using the instruction "tabrdc [m]", where the table location is defned by registers tblp and tbhp. here the confguration option has enabled the tbhp register. using the instruction "tabrdl [m]", where the table location is defned by registers tblp in the last page which has the address range 0f00h~0fffh. only the destination of the lower-order byte in the table is well-defned, the other bits of the table word are transferred to the lower portion of tblh, and the remaining 1-bit words are read as "0". the table higher-order byte register (tblh) is read only. the table pointers, tblp and tbhp, are read/write registers, which indicate the table location. before accessing the the table, the locations must be placed in the tblp and tbhp registers (if the confguration option has disabled tbhp then the value in tbhp has no effect). tblh is read only and cannot be restored. if the main routine and the isr (interrupt service routine) both employ the table read instruction, the contents of the tblh in the main routine are likely to be changed by the table read instruction used in the isr and errors can occur. using the table read instruction in the main routine and the isr simultaneously should be avoided. however, if the table read instruction has to be applied in both the main routine and the isr, the interrupt should be disabled prior to the table read instruction. it will not be enabled until the tblh has been backed up. all table related instructions require two cycles to complete the
rev. 1.00 18 october 27, 2011 rev. 1.00 19 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface operation. these areas may function as normal program memory depending on the requirements. once tbhp is enabled, the instruction "tabrdc [m]" reads the program memory data as defned by the tblp and tbhp values. if the program memory code option has disabled tbhp, the instruction "tabrdc [m]" reads the program memory data as defned by tblp only in the current program memory page. look-up table any location within the program memory can be defned as a look-up table where programmers can store fxed data. to use the look-up table, the table pointer must frst be setup by placing the lower order address of the look up data to be retrieved in the tblp register and the higher order address in the tbhp register. these two registers defne the full address of the look-up table. using the tbhp must be selected by confguration option, if not used table data can still be accessed but only the lower byte address in the current page or last page can be defned. after setting up the table pointers, the table data can be retrieved from the current program memory page or last program memory page using the "tabrdc [m]" or "tabrdl [m]" instructions, respectively. when these instructions are executed, the lower order table byte from the program memory will be transferred to the user defined data memory register [m] as specified in the instruction. the higher order table data byte from the program memory will be transferred to the tblh special register. any unused bits in this transferred higher order byte will be read as "0".                       
                             table read C tblp only                
                                table read C tblp/tbhp instruction table location bits b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 tabrdc [m] pc11 pc10 pc9 pc8 @7 @6 @5 @4 @3 @2 @1 @0 tabrdl [m] 1 1 1 1 @7 @6 @5 @4 @3 @2 @1 @0 table location note: pc11~pc8: current program counter bits. tbhp register bit3~0 when tbhp is enabled. @7~@0: table pointer tblp bits table high byte pointer for current table read tbhp (address 0x1f) register bits read/write functions tbhp(0x1f) 3~0 r/w store current table read bit11~bit8 data
rev. 1.00 18 october 27, 2011 rev. 1.00 19 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface table program example the following example shows how the table pointer and table data is defned and retrieved from the microcontroller. this example uses raw table data located in the last page which is stored there using the org statement. the value at this org statement is "f00h" which refers to the start address of the last page within the 4k program memory of device. the table pointer is setup here to have an initial value of "06h". this will ensure that the frst data read from the data table will be at the program memory address "f06h" or 6 locations after the start of the last page. note that the value for the table pointer is referenced to the frst address of the present page if the "tabrdc [m]" instruction is being used. the high byte of the table data which in this case is equal to zero will be transferred to the tblh register automatically when the "tabrdl [m]" instruction is executed. tempreg1 db ? ; temporary register #1 tempreg2 db ? ; temporary register #2 : : mov a,06h ; initialise table pointer-note that this ; address is referenced mov tblp,a ; to the last page or present page : : tabrdl tempreg1 ; transfers value in table referenced by table ; pointer to tempregl data at prog. memory ; address "f06h" transferred to tempreg1 and tblh dec tblp ; reduce value of table pointer by one tabrdl tempreg2 ; transfers value in table referenced by table ; pointer to tempreg2 data at prog. memory ; address "f05h" transferred to tempreg2 and tblh ; in this example the data "1ah" is transferred ; to tempreg1 and data "0fh" to register tempreg2 ; the value "00h" will be transferred to the high ; byte register tblh : : org f00h ; sets initial address of last page dc 00ah, 00bh, 00ch, 00dh, 00eh, 00fh, 01ah, 01bh : : because the tblh register is a read-only register and cannot be restored, care should be taken to ensure its protection if both the main routine and interrupt service routine use the table read instructions. if using the table read instructions, the interrupt service routines may change the value of tblh and subsequently cause errors if used again by the main routine. as a rule it is recommended that simultaneous use of the table read instructions should be avoided. however, in situations where simultaneous use cannot be avoided, the interrupts should be disabled prior to the execution of any main routine table-read instructions. note that all table related instructions require two instruction cycles to complete their operation.
rev. 1.00 20 october 27, 2011 rev. 1.00 21 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface data memory the data memory is a volatile area of 8-bit wide ram internal memory and is the location where temporary information is stored. the data memory is divided into two banks, bank0 and bank1. the bank0 is subdivided into two sections; the frst of these is an area of ram where special function registers are located. these registers have fxed locations and are necessary for correct operation of the device. many of these registers can be read from and written to directly under program control, however, some remain protected from user manipulation. the second area of data memory is reserved for general purpose use. in addition, the bank1 is dedicated for the usb related registers. all locations within this data memory are read and write accessible under program control. structure the data memory is subdivided into two banks, all of which are implemented in 8-bit wide ram. the data memory located in bank0 is subdivided into two sections, the special purpose and general purpose data memory. the start address of the data memory for all devices is the address 00h. registers which are common to all microcontrollers, such as acc, pcl, etc., have the same data memory address. the usb control registers is mapped into bank1. general purpose data memory all microcontroller programs require an area of read/write memory where temporary data can be stored and retrieved for use later. it is this area of ram memory that is known as general purpose data memory. this area of data memory is fully accessible by the user program for both read and write operations. by using the "set [m].i" and "clr [m].i" instructions, individual bits can be set or reset under program control giving the user a large range of fexibility for bit manipulation in the data memory. 01h bank1 bank0 25h 3fh 40h : unused, read as ?00? dfh usb iar0 mp0 00h 4ah special purpose registers general purpose registers iar0 mp0 data memory structure note: most of the data memory bits can be directly manipulated using the "set [m].i" and "clr [m].i" with the exception of a few dedicated bits. the data memory can also be accessed through the memory pointer register mp.
rev. 1.00 20 october 27, 2011 rev. 1.00 21 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface                                                  
                  ? ? ? ? ? ? ?? ?? ? ? ? ?  ?  ?   ?   ?  ? ?            ?  ? ?  ?  ?  ?  ?  ?  ?              ?? ?? ?   ? ? ? ?  ?? ? ?    ? ?  ?  ? ?? ?  -   -   -       special purpose data memory special function registers to ensure successful operation of the microcontroller, certain internal registers are implemented in the data memory area. these registers ensure correct operation of internal functions such as timers, interrupts, etc., as well as external functions such as i/o data control. the location of these registers within the data memory begins at the address 00h. any unused data memory locations between these special function registers and the point where the general purpose memory begins is reserved and attempting to read data from these locations will return a value of 00h. indirect addressing register C iar0, iar1 the indirect addressing registers, iar0 and iar1, although having their locations in normal ram register space, do not actually physically exist as normal registers. the method of indirect addressing for ram data manipulation uses these indirect addressing registers and memory pointers, in contrast to direct memory addressing, where the actual memory address is specifed. actions on the iar0 and iar1 registers will result in no actual read or write operation to these registers but rather to the memory location specifed by their corresponding memory pointer, mp0 or mp1. acting as a pair, iar0 and mp0 can together only access data from bank 0, while the iar1 and mp1 register pair can access data from both bank 0 and bank 1. as the indirect addressing registers are not physically implemented, reading the indirect addressing registers indirectly will return a result of "00h" and writing to the registers indirectly will result in no operation.
rev. 1.00 22 october 27, 2011 rev. 1.00 23 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface memory pointer C mp0, mp1 for all devices, two memory pointers, known as mp0 and mp1 are provided. these memory pointers are physically implemented in the data memory and can be manipulated in the same way as normal registers providing a convenient way with which to address and track data. when any operation to the relevant indirect addressing registers is carried out, the actual address that the microcontroller is directed to, is the address specifed by the related memory pointer. mp0 can only access data in bank 0 while mp1 can access both banks. data .section "data" adres1 db ? adres2 db ? adres3 db ? adres4 db ? block db ? code .section at 0 "code" org 00h start: mov a,04h ; setup size of block mov block,a mov a,offset adres1 ; accumulator loaded with frst ram address mov mp0,a ; setup memory pointer with frst ram address loop: clr iar0 ; clear the data at address defned by mp0 inc mp0 ; increment memory pointer sdz block ; check if last memory location has been cleared jmp loop continue: the important point to note here is that in the example shown above, no reference is made to specifc data memory addresses. accumulator C acc the accumulator is central to the operation of any microcontroller and is closely related with operations carried out by the alu. the accumulator is the place where all intermediate results from the alu are stored. without the accumulator it would be necessary to write the result of each calculation or logical operation such as addition, subtraction, shift, etc., to the data memory resulting in higher programming and timing overheads. data transfer operations usually involve the temporary storage function of the accumulator; for example, when transferring data between one user defined register and another, it is necessary to do this by passing the data through the accumulator as no direct transfer between two registers is permitted. program counter low register C pcl to provide additional program control functions, the low byte of the program counter is made accessible to programmers by locating it within the special purpose area of the data memory. by manipulating this register, direct jumps to other program locations are easily implemented. loading a value directly into this pcl register will cause a jump to the specifed program memory location, however, as the register is only 8-bit wide, only jumps within the current program memory page are permitted. when such operations are used, note that a dummy cycle will be inserted.
rev. 1.00 22 october 27, 2011 rev. 1.00 23 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface look-up table registers C tblp, tblh, tbhp these two special function registers are used to control operation of the look-up table which is stored in the program memory. tblp and tbhp are the table pointers and indicate the location where the table data is located. their value must be setup before any table read commands are executed. their values can be changed, for example using the "inc" or "dec" instructions, allowing for easy table data pointing and reading. tblh is the location where the high order byte of the table data is stored after a table read data instruction has been executed. status register C status this 8-bit register contains the zero fag (z), carry fag (c), auxiliary carry fag (ac), overfow fag (ov), power down fag (pdf), and watchdog time-out fag (to). these arithmetic/logical operation and system management fags are used to record the status and operation of the microcontroller. with the exception of the to and pdf fags, bits in the status register can be altered by instructions like most other registers. any data written into the status register will not change the to or pdf fag. in addition, operations related to the status register may give different results due to the different instruction operations. the to fag can be affected only by a system power-up, a wdt time-out or by executing the "clr wdt" or "halt" instruction. the pdf fag is affected only by executing the "halt" or "clr wdt" instruction or during a system power-up. the z, ov, ac and c fags generally refect the status of the latest operations. ? c is set if an operation results in a carry during an addition operation or if a borrow does not take place during a subtraction operation; otherwise c is cleared. c is also affected by a rotate through carry instruction. ? ac is set if an operation results in a carry out of the low nibbles in addition, or no borrow from the high nibble into the low nibble in subtraction; otherwise ac is cleared. ? z is set if the result of an arithmetic or logical operation is zero; otherwise z is cleared. ? ov is set if an operation results in a carry into the highest-order bit but not a carry out of the highest-order bit, or vice versa; otherwise ov is cleared. ? pdf is cleared by a system power-up or executing the "clr wdt" instruction. pdf is set by executing the "halt" instruction. ? to is cleared by a system power-up or executing the "clr wdt" or "halt" instruction. to is set by a wdt time-out. in addition, on entering an interrupt sequence or executing a subroutine call, the status register will not be pushed onto the stack automatically. if the contents of the status registers are important and if the interrupt routine can change the status register, precautions must be taken to correctly save it.
rev. 1.00 24 october 27, 2011 rev. 1.00 25 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface status register bit 7 6 5 4 3 2 1 0 name to pdf ov z ac c r/w r r r/w r/w r/w r/w por 0 0 x x x x x unknown bit 7, 6 unimplemented, read as 0 bit 5 to: watchdog time-out fag 0: after power up or executing the clr wdt or halt instruction 1: a watchdog time-out occurred bit 4 pdf: power down fag 0: after power up or executing the clr wdt instruction 1: by executing the halt instruction bit 3 ov: overfow fag 0: no overfow 1: an operation results in a carry into the highest-order bit but not a carry out of the highest-order bit or vice versa bit 2 z: zero fag 0: the result of an arithmetic or logical operation is not zero 1: the result of an arithmetic or logical operation is zero bit 1 ac: auxiliary fag 0: no auxiliary carry 1: an operation results in a carry out of the low nibbles in addition, or no borrow from the high nibble into the low nibble in subtraction bit 0 c: carry fag 0: no carry-out 1: an operation results in a carry during an addition operation or if a borrow does not take place during a subtraction operation c is also affected by a rotate through carry instruction. bank pointer C bp the special purpose data memory is divided into two banks, bank 0 and bank 1. the usb control registers are located in bank 1, while all other registers are located in bank 0. the bank pointer selects which bank data is to be accessed from. if bank 0 is to be accessed then bp must be set to a value of 00h, while if bank 1 is to be accessed then bp must be set to a value of 01h.                             
           bank pointer
rev. 1.00 24 october 27, 2011 rev. 1.00 25 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface input/output ports holtek microcontrollers offer considerable fexibility on their i/o ports. with the input or output designation of every pin fully under user program control, pull-high options for all ports and wake-up options on certain pins, the user is provided with an i/o structure to meet the needs of a wide range of application possibilities. depending upon which package is chosen, the microcontroller provides up to 15 bidirectional input/output lines labeled with port names pa, pb and pe. these i/o ports are mapped to the data memory with addresses as shown in the special purpose data memory table. for input operation, these ports are non-latching, which means the inputs must be ready at the t2 rising edge of instruction "mov a,[m]", where m denotes the port address. for output operation, all the data is latched and remains unchanged until the output latch is rewritten. pull-high resistors many product applications require pull-high resistors for their switch inputs usually requiring the use of an external resistor. to eliminate the need for these external resistors, i/o pins, when confgured as an input have the capability of being connected to an internal pull-high resistor. the pull-high resistors are selectable via confguration options and are implemented using weak pmos transistors. a pin or nibble option on the i/o ports can be selected to select pull-high resistors. note that the pe2 is pin shared with reset pin, the i/o structure is nmos open drain, and there is no pull-high resistor for this pin. port a cmos/nmos/pmos structure the pins on port a can be setup via configuration option to be either cmos, nmos or pmos types. port a vdd/v33o option structure the power supply for the port a pins can be setup via confguration option to be either vdd or v33o. port pin wake-up if the halt instruction is executed, the device will enter the power down mode, where the system clock will stop resulting in power being conserved, a feature that is important for battery and other low-power applications. various methods exist to wake-up the microcontroller, one of which is to change the logic condition on one of the port pins from high to low. after a halt instruction forces the microcontroller into entering the power down mode, the processor will remain in a low-power state until the logic condition of the selected wake-up pin on the port pin changes from high to low. this function is especially suitable for applications that can be woken up via external switches. each pin on pa, pb and pe has the capability to wake-up the device on an external falling edge. note that some pins can only be setup nibble wide whereas other can be bit selected to have a wake-up function.
rev. 1.00 26 october 27, 2011 rev. 1.00 27 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface i/o port control registers each i/o port has its own control register pac, pbc and pec, to control the input/output configuration. with this control register, each cmos output or input with or without pull-high resistor structures can be reconfgured dynamically under software control. each of the i/o ports is directly mapped to a bit in its associated port control register. note that several pins can be setup to have nmos outputs using confguration options. for the i/o pin to function as an input, the corresponding bit of the control register must be written as a "1". this will then allow the logic state of the input pin to be directly read by instructions. when the corresponding bit of the control register is written as a "0", the i/o pin will be setup as an output. if the pin is currently setup as an output, instructions can still be used to read the output register. however, it should be noted that the program will in fact only read the status of the output data latch and not the actual logic status of the output pin. pin-shared functions the fexibility of the microcontroller range is greatly enhanced by the use of pins that have more than one function. limited numbers of pins can force serious design constraints on designers but by supplying pins with multi-functions, many of these diffculties can be overcome. for some pins, the chosen function of the multi-function i/o pins is set by confguration options while for others the function is set by application program control. ? external timer0 clock input the external timer pin tmr0 is pin-shared with the i/o pin pa6. to confgure this pin to operate as timer input, the corresponding control bits in the timer control register must be correctly set. for applications that do not require an external timer input, this pin can be used as a normal i/o pin. note that if used as a normal i/o pin the timer mode control bits in the timer control register must select the timer mode, which has an internal clock source, to prevent the input pin from interfering with the timer operation. ? external timer1 clock input the external timer pin tmr1 is pin-shared with the i/o pin pa7. to confgure this pin to operate as timer input, the corresponding control bits in the timer control register must be correctly set. for applications that do not require an external timer input, this pin can be used as a normal i/o pin. note that if used as a normal i/o pin the timer mode control bits in the timer control register must select the timer mode, which has an internal clock source, to prevent the input pin from interfering with the timer operation. i/o pin structures the diagram illustrates a generic i/o pin internal structures. as the exact logical construction of the i/o pin will differ and as the pin-shared structures are not illustrated this diagram is supplied as a guide only to assist with the functional understanding of the i/o pins.
rev. 1.00 26 october 27, 2011 rev. 1.00 27 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface               
            
   ? ??   ? ??  ?   ? ?
  ?  
 ?   ?  
   ??
     ?   ?  
   
    
    ?
- 
 ? ?    ??  ?? ?
 ? 
 input/output ports                   
            ?     ?     ? ?    ?        ?      ?          ?                 ?      ? 
  ?
 ?   input/output port (pe2)
rev. 1.00 28 october 27, 2011 rev. 1.00 29 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface programming considerations within the user program, one of the frst things to consider is port initialisation. after a reset, all of the data and port control register will be set high. this means that all i/o pins will default to an input state, the level of which depends on the other connected circuitry and whether pull-high options have been selected. if the pac, pbc and pec port control register, are then programmed to setup some pins as outputs, these output pins will have an initial high output value unless the associated pa, pb and pe port data registers are frst programmed. selecting which pins are inputs and which are outputs can be achieved byte-wide by loading the correct value into the port control register or by programming individual bits in the port control register using the "set [m].i" and "clr [m].i" instructions. note that when using these bit control instructions, a read-modify-write operation takes place. the microcontroller must frst read in the data on the entire port, modify it to the required new bit values and then rewrite this data back to the output ports.                        
       read/write timing all pins have the additional capability of providing wake-up functions. when the device is in the power down mode, various methods are available to wake the device up. one of these is a high to low transition of any of the port pins. single or multiple pins can be setup to have this function. timer/event counters the provision of timers form an important part of any microcontroller, giving the designer a means of carrying out time related functions. this device contains two count-up timers of 8-bit and 16-bit capacities respectively. as each timer has three different operating modes, they can be confgured to operate as a general timer, an external event counter or as a pulse width measurement device. there are two types of registers related to the timer/event counters. the first is the register that contains the actual value of the timer/event counter and into which an initial value can be preloaded, and is known as tmr0, tmr1h or tmr1l. reading from this register retrieves the contents of the timer/event counter. the second type of associated register is the timer control register, which defnes the timer options and determines how the timer/event counter is to be used, and has the name tmr0c or tmr1c. this device can have the timer clocks confgured to come from the internal clock sources. in addition, the timer clock source can also be confgured to come from the external timer pins. the external clock source is used when the timer/event counter is in the event counting mode, the clock source being provided on the external timer pin. the pin has the name tmr0 or tmr1 and is pin-shared with an i/o pin. depending upon the condition of the t0e or t1e bit in the timer control register, each high to low, or low to high transition on the external timer input pin will increment the timer/event counter by one.
rev. 1.00 28 october 27, 2011 rev. 1.00 29 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface confguring the timer/event counter input clock source the timer/event counter's clock can originate from various sources. the system clock source is used when the timer/event counter 0 is in the timer mode or in the pulse width measurement mode. the instruction clock source (system clock source divided by 4) is used when the timer/event counter 1 is in the timer mode or in the pulse width measurement mode. the external clock source is used when the timer/event counter is in the event counting mode, the clock source being provided on the external timer pin, tmr0 or tmr1. depending upon the condition of the t0e or t1e bit, each high to low, or low to high transition on the external timer pin will increment the counter by one.                     
                                    ?             ?    ?? ? ? 8-bit timer/event counter 0 structure                     
           
              ? 
? 
      ?  ? ? ? 
?  ? 
?  
             -?- ? 16-bit timer/event counter 1 structure timer register C tmr0, tmr1l/tmr1h the timer registers are special function registers located in the special purpose ram data memory and are the places where the actual timer values are stored. for 8-bit timer/event counter 0, this register is known as tmr0. for 16-bit timer/event counter 1, the timer registers are known as tmr1l and tmr1h. the value in the timer registers increases by one each time an internal clock pulse is received or an external transition occurs on the external timer pin. the timer will count from the initial value loaded by the preload register to the full count of ffh for the 8-bit timer or ffffh for the 16-bit timer at which point the timer overfows and an internal interrupt signal is generated. the timer value will then be reset with the initial preload register value and continue counting. to achieve a maximum full range count of ffh for the 8-bit timer or ffffh for the 16-bit timer, the preload registers must frst be cleared to all zeros. it should be noted that after power-on, the preload register will be in an unknown condition. note that if the timer/event counter is switched off and data is written to its preload registers, this data will be immediately written into the actual timer registers. however, if the timer/event counter is enabled and counting, any new data written into the preload data registers during this period will remain in the preload registers and will only be written into the timer registers the next time an overfow occurs.
rev. 1.00 30 october 27, 2011 rev. 1.00 31 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface for the 16-bit timer/event counter which has both low byte and high byte timer registers, accessing these registers is carried out in a specifc way. it must be note when using instructions to preload data into the low byte timer register, namely tmr1l, the data will only be placed in a low byte buffer and not directly into the low byte timer register. the actual transfer of the data into the low byte timer register is only carried out when a write to its associated high byte timer register, namely tmr1h, is executed. on the other hand, using instructions to preload data into the high byte timer register will result in the data being directly written to the high byte timer register. at the same time the data in the low byte buffer will be transferred into its associated low byte timer register. for this reason, the low byte timer register should be written frst when preloading data into the 16-bit timer registers. it must also be noted that to read the contents of the low byte timer register, a read to the high byte timer register must be executed frst to latch the contents of the low byte timer register into its associated low byte buffer. after this has been done, the low byte timer register can be read in the normal way. note that reading the low byte timer register will result in reading the previously latched contents of the low byte buffer and not the actual contents of the low byte timer register. timer control register C tmr0c/tmr1c the fexible features of the holtek microcontroller timer/event counters enable them to operate in three different modes, the options of which are determined by the contents of their respective control register. for devices are two timer control registers known as tmr0c, tmr1c. it is the timer control register together with its corresponding timer registers that control the full operation of the timer/event counters. before the timers can be used, it is essential that the appropriate timer control register is fully programmed with the right data to ensure its correct operation, a process that is normally carried out during program initialization. to choose which of the three modes the timer is to operate in, either in the timer mode, the event counting mode or the pulse width measurement mode, bits 7 and 6 of the timer control register, which are known as the bit pair t0m1/t0m0 or t1m1/t1m0 respectively, depending upon which timer is used, must be set to the required logic levels. the timer-on bit, which is bit 4 of the timer control register and known as t0on or t1on, depending upon which timer is used, provides the basic on/off control of the respective timer. setting the bit high allows the counter to run, clearing the bit stops the counter. if the timer is in the event count or pulse width measurement mode, the active transition edge level type is selected by the logic level of bit 3 of the timer control register which is known as t0e or t1e, depending upon which timer is used.
rev. 1.00 30 october 27, 2011 rev. 1.00 31 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface tmr0c register bit 7 6 5 4 3 2 1 0 name t0m1 t0m0 D t0on t0e D D D r/w r/w r/w D r/w r/w D D D por 0 0 D 0 1 D D D bit 7, 6 t0m1, t0m0: timer 0 operation mode selection 00: no mode available 01: event counter mode 10: timer mode 11: pulse width capture mode bit 5 unimplemented bit 4 t0on: timer/event counter counting enable 0: disable 1: enable bit 3 t0e: event counter active edge selection 0: count on rising edge 1: count on falling edge pulse width capture active edge selection 0: start counting on falling edge, stop on rising edge 1: start counting on rising edge, stop on falling edge bit 2~0 unimplemented tmr1c register bit 7 6 5 4 3 2 1 0 name t1m1 t1m0 D t1on t1e D D D r/w r/w r/w D r/w r/w D D D por 0 0 D 0 1 D D D bit 7, 6 t1m1, t1m0: timer 1 operation mode selection 00: no mode available 01: event counter mode 10: timer mode 11: pulse width capture mode bit 5 unimplemented bit 4 t1on: timer/event counter counting enable 0: disable 1: enable bit 3 t1e: event counter active edge selection 0: count on rising edge 1: count on falling edge pulse width capture active edge selection 0: start counting on falling edge, stop on rising edge 1: start counting on rising edge, stop on falling edge bit 2~0 unimplemented
rev. 1.00 32 october 27, 2011 rev. 1.00 33 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface confguring the timer mode in this mode, the timer/event counter can be utilised to measure fxed time intervals, providing an internal interrupt signal each time the timer/event counter overfows. to operate in this mode, the operating mode select bit pair, t0m1/t0m0 or t1m1/t1m0, in the timer control register must be set to the correct value as shown. control register operating mode select bits for the timer mode bit7 bit6 1 0 in this mode the internal clock, f sys /4 is used as the internal clock for the timer/event counters. after the other bits in the timer control register have been setup, the enable bit t0on or t1on, which is bit 4 of the timer control register, can be set high to enable the timer/event counter to run. each time an internal clock cycle occurs, the timer/event counter increments by one. when it is full and overfows, an interrupt signal is generated and the timer/event counter will reload the value already loaded into the preload register and continue counting. the interrupt can be disabled by ensuring that the timer/event counter interrupt enable bit in the interrupt control register, intc0, is reset to zero.                             
           timer mode timing chart confguring the event counter mode in this mode, a number of externally changing logic events, occurring on the external timer pin, can be recorded by the timer/event counter. to operate in this mode, the operating mode select bit pair, t0m1/t0m0 or t1m1/t1m0, in the timer control register must be set to the correct value as shown. control register operating mode select bits for the event counter mode bit7 bit6 0 1 in this mode, the external timer pin, tmr0 or tmr1, is used as the timer/event counter clock source, however it is not divided by the internal prescaler. after the other bits in the timer control register have been setup, the enable bit t0on or t1on, which is bit 4 of the timer control register, can be set high to enable the timer/event counter to run. if the active edge select bit t0e or t1e, which is bit 3 of the timer control register, is low, the timer/event counter will increment each time the external timer pin receives a low to high transition. if the active edge select bit is high, the counter will increment each time the external timer pin receives a high to low transition. when it is full and overflows, an interrupt signal is generated and the timer/event counter will reload the value already loaded into the preload register and continue counting. the interrupt can be disabled by ensuring that the timer/event counter interrupt enable bit in the interrupt control register, intc0, is reset to zero. as the external timer pin is shared with an i/o pin, to ensure that the pin is confgured to operate as an event counter input pin, two things have to happen. the frst is to ensure that the operating mode select bits in the timer control register place the timer/event counter in the event counting mode, the second is to ensure that the port control register confgures the pin as an input. it should be noted that in the event counting mode, even if the microcontroller is in the power down mode, the timer/event counter will continue to record externally changing logic events on the timer input pin. as a result when the timer overfows it will generate a timer interrupt and corresponding wake-up source.
rev. 1.00 32 october 27, 2011 rev. 1.00 33 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface                             
event counter mode timing chart confguring the pulse width measurement mode in this mode, the timer/event counter can be utilised to measure the width of external pulses applied to the external timer pin. to operate in this mode, the operating mode select bit pair, t0m1/t0m0 or t1m1/t1m0, in the timer control register must be set to the correct valueas shown. control register operating mode select bits for the pulse width capture mode bit7 bit6 1 1 in this mode the internal clock, f sys /4 is used as the internal clock for the timer/event counters. after the other bits in the timer control register have been setup, the enable bit t0on or t1on, which is bit 4 of the timer control register, can be set high to enable the timer/event counter, however it will not actually start counting until an active edge is received on the external timer pin. if the active edge select bit t0e or t1e, which is bit 3 of the timer control register, is low, once a high to low transition has been received on the external timer pin, tmr0 or tmr1, the timer/event counter will start counting until the external timer pin returns to its original high level. at this point the enable bit will be automatically reset to zero and the timer/event counter will stop counting. if the active edge select bit is high, the timer/event counter will begin counting once a low to high transition has been received on the external timer pin and stop counting when the external timer pin returns to its original low level. as before, the enable bit will be automatically reset to zero and the timer/event counter will stop counting. it is important to note that in the pulse width measurement mode, the enable bit is automatically reset to zero when the external control signal on the external timer pin returns to its original level, whereas in the other two modes the enable bit can only be reset to zero under program control. the residual value in the timer/event counter, which can now be read by the program, therefore represents the length of the pulse received on the external timer pin. as the enable bit has now been reset, any further transitions on the external timer pin will be ignored. not until the enable bit is again set high by the program can the timer begin further pulse width measurements. in this way, single shot pulse measurements can be easily made. it should be noted that in this mode the timer/event counter is controlled by logical transitions on the external timer pin and not by the logic level. when the timer/event counter is full and overfows, an interrupt signal is generated and the timer/event counter will reload the value already loaded into the preload register and continue counting. the interrupt can be disabled by ensuring that the timer/event counter interrupt enable bit in the interrupt control register, intc0, is reset to zero. as the external timer pin is shared with an i/o pin, to ensure that the pin is confgured to operate as a pulse width measurement pin, two things have to happen. the frst is to ensure that the operating mode select bits in the timer control register place the timer/event counter in the pulse width measurement mode, the second is to ensure that the port control register confgures the pin as an input.
rev. 1.00 34 october 27, 2011 rev. 1.00 35 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface                   
        
    
                 ?                  ?   ? ? ?  ? ??  ?  - pulse width capture mode timing chart i/o interfacing the timer/event counter, when confgured to run in the event counter or pulse width measurement mode, require the use of the external tmr0 and tmr1 pins for correct operation. as these pins are shared pins they must be confgured correctly to ensure they are setup for use as timer/event counter inputs and not as a normal i/o pins. this is implemented by ensuring that the mode select bits in the timer/event counter control register, select either the event counter or pulse width measurement mode. additionally the port control register bits for these pins must be set high to ensure that the pin is setup as an input. any pull-high resistor confguration option on these pins will remain valid even if the pin is used as a timer/event counter input. programming considerations when configured to run in the timer mode, the internal system clock is used as the timer clock source and is therefore synchronised with the overall operation of the microcontroller. in this mode when the appropriate timer register is full, the microcontroller will generate an internal interrupt signal directing the program flow to the respective internal interrupt vector. for the pulse width measurement mode, the internal system clock is also used as the timer clock source but the timer will only run when the correct logic condition appears on the external timer input pin. as this is an external event and not synchronised with the internal timer clock, the microcontroller will only see this external event when the next timer clock pulse arrives. as a result, there may be small differences in measured values requiring programmers to take this into account during programming. the same applies if the timer is configured to be in the event counting mode, which again is an external event and not synchronised with the internal system or timer clock. when the timer/event counter is read, or if data is written to the preload register, the clock is inhibited to avoid errors, however as this may result in a counting error, this should be taken into account by the programmer. care must be taken to ensure that the timers are properly initialised before using them for the first time. the associated timer enable bits in the interrupt control register must be properly set otherwise the internal interrupt associated with the timer will remain inactive. the edge select timer mode and clock source control bits in timer control register must also be correctly set to ensure the timer is properly configured for the required application. it is also important to ensure that an initial value is frst loaded into the timer registers before the timer is switched on; this is because after power-on the initial values of the timer registers are unknown. after the timer has been initialised the timer can be turned on and off by controlling the enable bit in the timer control register. note that setting the timer enable bit high to turn the timer on, should only be executed after the timer mode bits have been properly setup. setting the timer enable bit high together with a mode bit modifcation, may lead to improper timer operation if executed as a single timer control register byte write instruction.
rev. 1.00 34 october 27, 2011 rev. 1.00 35 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface when the timer/event counter overfows, its corresponding interrupt request fag in the interrupt control register will be set. if the timer interrupt is enabled this will in turn generate an interrupt signal. however irrespective of whether the interrupts are enabled or not, a timer/event counter overflow will also generate a wake-up signal if the device is in a power-down condition. this situation may occur if the timer/event counter is in the event counting mode and if the external signal continues to change state. in such a case, the timer/event counter will continue to count these external events and if an overfow occurs the device will be woken up from its power-down condition. to prevent such a wake-up from occurring, the timer interrupt request fag should frst be set high before issuing the "halt" instruction to enter the power down mode. timer program example this program example shows how the timer/event counter registers are setup, along with how the interrupts are enabled and managed. note how the timer/event counter is turned on, by setting bit 4 of the timer control register. the timer/event counter can be turned off in a similar way by clearing the same bit. this example program sets the timer/event counter to be in the timer mode, which uses the internal system clock as the clock source. org 04h ; usb interrupt vector reti org 08h ; timer/event counter interrupt vector jmp tmr0int ; jump here when timer0 overfows : org 20h ; main program ;internal timer/event counter 0 interrupt routine tmr0int: : ; timer/event counter 0 main program placed here : reti : : begin: ;setup timer registers mov a,09bh ; setup timer preload value mov tmr0,a; mov a,080h ; setup timer control register mov tmr0c,a ; timer mode ; setup interrupt register mov a,005h ; enable master interrupt and timer interrupt mov intc0,a set tmr0c.4 ; start timer/event counter - note mode bits must be ; previously setup
rev. 1.00 36 october 27, 2011 rev. 1.00 37 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface interrupts interrupts are an important part of any microcontroller system. when an internal function such as a timer/event counter overflow, a usb interrupt occur, or a spi interrupt takes place, their corresponding interrupt will enforce a temporary suspension of the main program allowing the microcontroller to direct attention to their respective needs while the internal interrupts are controlled by the timer/event counter overfow, usb interrupt or reception and the spi one byte reception or transmission. interrupt registers overall interrupt control, which means interrupt enabling and request fag setting, is controlled by the interrupt control registers, intc0 and intc1. by controlling the appropriate enable bits in the registers each individual interrupt can be enabled or disabled. also when an interrupt occurs, the corresponding request fag will be set by the microcontroller. the global enable fag if cleared to zero will disable all interrupts. intc0 register bit 7 6 5 4 3 2 1 0 name D t1f t0f usbf et1i et0i eui emi r/w D r/w r/w r/w r/w r/w r/w r/w por D 0 0 0 0 0 0 0 bit 7 unimplemented, read as 0 bit 6 t1f: timer/event counter 1 interrupt request fag 0: inactive 1: active bit 5 t0f: timer/event counter 0 interrupt request fag 0: inactive 1: active bit 4 usbf: usb interrupt request fag 0: inactive 1: active bit 3 et1i: timer/event counter 1 interrupt enable 0: disable 1: enable bit 2 et0i: timer/event counter 0 interrupt enable 0: disable 1: enable bit 1 eui: usb interrupt enable 0: disable 1: enable bit 0 emi: master interrupt global enable 0: disable 1: enable
rev. 1.00 36 october 27, 2011 rev. 1.00 37 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface intc1 register bit 7 6 5 4 3 2 1 0 name D D D sif D D D esii r/w D D D r/w D D D r/w por D D D 0 D D D 0 bit 7~5 unimplemented, read as 0 bit 4 sif: spi interrupt request fag 0: inactive 1: active bit 3~1 unimplemented, read as 0 bit 0 esii: spi interrupt enable 0: disable 1: enable interrupt operation when a usb interrupt occurs, a spi insterrupt takes place, or one of the timer/event counters overflow, if their appropriate interrupt enable bit is set, the program counter, which stores the address of the next instruction to be executed, will be transferred onto the stack. the program counter will then be loaded with a new address which will be the value of the corresponding interrupt vector. the microcontroller will then fetch its next instruction from this interrupt vector. the instruction at this vector will usually be a jmp statement which will jump to another section of program which is known as the interrupt service routine. here is located the code to control the appropriate interrupt. the interrupt service routine must be terminated with a reti statement, which retrieves the original program counter address from the stack and allows the microcontroller to continue with normal execution at the point where the interrupt occurred. the various interrupt enable bits, together with their associated request flags, are shown in the accompanying diagram with their order of priority. once an interrupt subroutine is serviced, all the other interrupts will be blocked, as the emi bit will be cleared automatically. this will prevent any further interrupt nesting from occurring. however, if other interrupt requests occur during this interval, although the interrupt will not be immediately serviced, the request fag will still be recorded. if an interrupt requires immediate servicing while the program is already in another interrupt service routine, the emi bit should be set after entering the routine, to allow interrupt nesting. if the stack is full, the interrupt request will not be acknowledged, even if the related interrupt is enabled, until the stack pointer is decremented. if immediate service is desired, the stack must be prevented from becoming full.                          
                                ? ?       ?                 ?  ? ?       - ?? 
            ? - ? - ? ?  ? ?       ? ?? 
            ? ? ? ?                 interrupt structure
rev. 1.00 38 october 27, 2011 rev. 1.00 39 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface interrupt priority interrupts, occurring in the interval between the rising edges of two consecutive t2 pulses, will be serviced on the latter of the two t2 pulses, if the corresponding interrupts are enabled. in case of simultaneous requests, the following table shows the priority that is applied. these can be masked by resetting the emi bit. interrupt source priority vector usb interrupt 1 0004h timer/event counter 0 overfow interrupt 2 0008h timer/event counter 1 overfow interrupt 3 000ch spi interrupt 4 0010h in cases where both external and internal interrupts are enabled and where an external and internal interrupt occurs simultaneously, the external interrupt will always have priority and will therefore be serviced frst. suitable masking of the individual interrupts using the interrupt registers can prevent simultaneous occurrences. timer/event counter interrupt for a timer/event counter interrupt to occur, the global interrupt enable bit, emi, and the corresponding timer interrupt enable bit, et0i/et1i, must first be set. an actual timer/event counter interrupt will take place when the timer/event counter interrupt request flag, t0f/t1f, is set, a situation that will occur when the timer/event counter overfows. when the interrupt is enabled, the stack is not full and a timer/event counter overfow occurs, a subroutine call to the timer interrupt vector at location 08h/0ch, will take place. when the interrupt is serviced, the timer interrupt request fag, t0f/t1f, will be automatically reset and the emi bit will be automatically cleared to disable other interrupts. programming considerations by disabling the interrupt enable bits, a requested interrupt can be prevented from being serviced, however, once an interrupt request fag is set, it will remain in this condition in the interrupt control register until the corresponding interrupt is serviced or until the request fag is cleared by a software instruction. it is recommended that programs do not use the "call subroutine" instruction within the interrupt subroutine. interrupts often occur in an unpredictable manner or need to be serviced immediately in some applications. if only one stack is left and the interrupt is not well controlled, the original control sequence will be damaged once a "call subroutine" is executed in the interrupt subroutine. all of these interrupts have the capability of waking up the processor when in the power down mode. only the program counter is pushed onto the stack. if the contents of the accumulator or status register are altered by the interrupt service program, which may corrupt the desired control sequence, then the contents should be saved in advance.
rev. 1.00 38 october 27, 2011 rev. 1.00 39 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface usb interrupt the usb interrupts are triggered by the following usb events causing the related interrupt request fag, usbf, to be set. ? access of the corresponding usb fifo from pc ? a usb suspend signal from the pc ? a usb resume signal from the pc ? a usb reset signal when the interrupt is enabled, the stack is not full and the usb interrupt is active, a subroutine call to location 04h will occur. the interrupt request fag, usbf, and the emi bit will be cleared to disable other interrupts. when the pc host accesses the fifo of the device, the corresponding request bit, usr, is set, and a usb interrupt is triggered. so the user can easy determine which fifo has been accessed. when the interrupt has been served, the corresponding bit should be cleared by frmware. when the device receive a usb suspend signal from host pc, the suspend line (bit 0 of usc) is set and a usb interrupt is also triggered. also when device receive a resume signal from host pc, the resume line (bit 3 of usc) is set and a usb interrupt is triggered. serial interface interrupt the serial interface interrupt, also known as the spi interrupt. a spi interrupt request will take place when the spi interrupt request fag, sif, is set, which occurs when a byte of data has been received or transmitted by the spi interface. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi, and the serial interface interrupt enable bit, esii, must frst be set. when the interrupt is enabled, the stack is not full and a byte of data has been transmitted or received by the spi interface, a subroutine call to the respective interrupt vector, will take place. when the serial interface interrupt is serviced, the emi bit will be automatically cleared to disable other interrupts, and the interrupt request fag, sif, will be also automatically cleared. reset and initialisation a reset function is a fundamental part of any microcontroller ensuring that the device can be set to some predetermined condition irrespective of outside parameters. the most important reset condition is after power is frst applied to the microcontroller. in this case, internal circuitry will ensure that the microcontroller, after a short delay, will be in a well defined state and ready to execute the frst program instruction. after this power-on reset, certain important internal registers will be set to defned states before the program commences. one of these registers is the program counter, which will be reset to zero forcing the microcontroller to begin program execution from the lowest program memory address. in addition to the power-on reset, situations may arise where it is necessary to forcefully apply a reset condition when the microcontroller is running. one example of this is where after power has been applied and the microcontroller is already running, the res line is forcefully pulled low. in such a case, known as a normal operation reset, some of the microcontroller registers remain unchanged allowing the microcontroller to proceed with normal operation after the reset line is allowed to return high. another type of reset is when the watchdog timer overfows and resets the microcontroller. all types of reset operations result in different register conditions being setup. another reset exists in the form of a low voltage reset, lvr, where a full reset, similar to the res reset is implemented in situations where the power supply voltage falls below a certain threshold.
rev. 1.00 40 october 27, 2011 rev. 1.00 41 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface reset functions there are five ways in which a microcontroller reset can occur, through events occurring both internally and externally: ? power-on reset the most fundamental and unavoidable reset is the one that occurs after power is frst applied to the microcontroller. as well as ensuring that the program memory begins execution from the frst memory address, a power-on reset also ensures that certain other registers are preset to known conditions. all the i/o port and port control registers will power up in a high condition ensuring that all pins will be frst set to inputs. although the microcontroller has an internal rc reset function, if the v dd power supply rise time is not fast enough or does not stabilise quickly at power-on, the internal reset function may be incapable of providing a proper reset operation. in such cases it is recommended that an external rc network is connected to the res pin, whose additional time delay will ensure that the res pin remains low for an extended period to allow the power supply to stabilise. during this time delay, normal operation of the microcontroller will be inhibited. after the res line reaches a certain voltage value, the reset delay time t rstd is invoked to provide an extra delay time after which the microcontroller will begin normal operation. the abbreviation sst in the fgures stands for system start-up timer.                
      power-on reset timing chart ? res pin reset for most applications a resistor connected between vdd and the res pin and a capacitor connected between vss and the res pin will provide a suitable external reset circuit. any wiring connected to the res pin should be kept as short as possible to minimise any stray noise interference.            basic reset circuit for applications that operate within an environment where more noise is present the enhanced reset circuit shown is recommended.                   enhanced reset circuit
rev. 1.00 40 october 27, 2011 rev. 1.00 41 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface more information regarding external reset circuits is located in application note ha0075e on the holtek website. this type of reset occurs when the microcontroller is already running and the res pin is forcefully pulled low by external hardware such as an external switch. in this case as in the case of other reset, the program counter will reset to zero and program execution initiated from this point. note that as the external reset pin is also pin-shared with pe2 if it is to be used as a reset pin, the correct reset confguration option must be selected.               

   res reset timing chart ? low voltage reset C lvr the microcontroller contains a low voltage reset circuit in order to monitor the supply voltage of the device. the lvr function is selected via a confguration option. if the supply voltage of the device drops to within a range of 0.9v~v lvr such as might occur when changing the battery, the lvr will automatically reset the device internally. for a valid lvr signal, a low supply voltage, i.e., a voltage in the range between 0.9v~v lvr must exist for a time greater than that specifed by t lvr in the a.c. characteristics. if the low supply voltage state does not exceed this value, the lvr will ignore the low supply voltage and will not perform a reset function. the actual v lvr value can be selected via confguration options.                  low voltage reset timing chart ? watchdog time-out reset during normal operation the watchdog time-out reset during normal operation is the same as a hardware res pin reset except that the watchdog time-out fag to will be set to "1".                      wdt time-out reset during normal operation timing chart ? watchdog time-out reset during power down the watchdog time-out reset during power down is a little different from other kinds of reset. most of the conditions remain unchanged except that the program counter and the stack pointer will be cleared to "0" and the to fag will be set to "1". refer to the a.c. characteristics for t sst details.              wdt time-out reset during power down timing char
rev. 1.00 42 october 27, 2011 rev. 1.00 43 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface reset initial conditions the different types of reset described affect the reset fags in different ways. these fags, known as pdf and to are located in the status register and are controlled by various microcontroller operations, such as the power down function or watchdog timer. the reset fags are shown in the table: to pdf reset conditions 0 0 res reset during power-on 0 0 res wake-up during power down 0 0 res or lvr reset during normal operation 1 u wdt time-out reset during normal operation 1 1 wdt time-out reset during power down note: "u" stands for unchanged the following table indicates the way in which the various components of the microcontroller are affected after a power-on reset occurs. item condition after reset program counter reset to zero interrupts all interrupts will be disabled wdt clear after reset, wdt begins counting timer/event counter timer counter will be turned off prescaler the timer counter prescaler will be cleared input/output ports i/o ports will be setup as inputs stack pointer stack pointer will point to the top of the stack the different kinds of resets all affect the internal registers of the microcontroller in different ways. to ensure reliable continuation of normal program execution after a reset occurs, it is important to know what condition the microcontroller is in after a particular reset occurs. the following table describes how each type of reset affects the microcontroller internal registers.
rev. 1.00 42 october 27, 2011 rev. 1.00 43 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface register reset (power on) wdt time- out (normal operation) res reset (normal operation) res reset (halt) wdt time- out (halt)* usb-reset (normal) usb-reset (halt) tmr0 xxxx xxxx 0000 0000 0000 0000 0000 0000 uuuu uuuu uuuu uuuu uuuu uuuu tmr0c 00-0 1--- 00-0 1--- 00-0 1--- 00-0 1--- uu-u u--- 00-0 1--- 00-0 1--- tmr1h xxxx xxxx 0000 0000 0000 0000 0000 0000 uuuu uuuu uuuu uuuu uuuu uuuu tmr1l xxxx xxxx 0000 0000 0000 0000 0000 0000 uuuu uuuu uuuu uuuu uuuu uuuu tmr1c 00-0 1--- 00-0 1--- 00-0 1--- 00-0 1--- uu-u u--- 00-0 1--- 00-0 1--- program counter 0000h 0000h 0000h 0000h 0000h 0000h 0000h mp0 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu mp1 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu acc xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu tblp xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu tbhp ---- xxxx ---- uuuu ---- uuuu ---- uuuu ---- uuuu ---- uuuu ---- uuuu tblh -xxx xxxx -uuu uuuu -uuu uuuu -uuu uuuu -uuu uuuu -uuu uuuu -uuu uuuu status --00 xxxx --1u uuuu --00 uuuu --00 uuuu --11 uuuu --uu uuuu --01 uuuu intc0 -000 0000 -000 0000 -000 0000 -000 0000 -uuu uuuu -000 0000 -000 0000 intc1 ---0 ---0 ---0 ---0 ---0 ---0 ---0 ---0 ---u ---u ---0 ---0 ---0 ---0 wdts 1000 0111 1000 0111 1000 0111 1000 0111 uuuu uuuu 1000 0111 1000 0111 pa 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111 pac 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111 pb ---- 1111 ---- 1111 ---- 1111 ---- 1111 ---- uuuu ---- 1111 ---- 1111 pbc ---- 1111 ---- 1111 ---- 1111 ---- 1111 ---- uuuu ---- 1111 ---- 1111 pe ---- -111 ---- -111 ---- -111 ---- -111 ---- -uuu ---- -111 ---- -111 pec ---- -111 ---- -111 ---- -111 ---- -111 ---- -uuu ---- -111 ---- -111 usb _ stat ---x xxxx ---u uuuu ---x xxxx ---x xxxx ---u uuuu ---x xxxx ---x xxxx pipe_ctrl 0000 0110 uuuu uuuu 0000 0110 0000 0110 uuuu uuuu 0000 0110 0000 0110 awr 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 pipe 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 stall 0000 0110 uuuu uuuu 0000 0110 0000 0110 uuuu uuuu 0000 0110 0000 0110 sies 0x0x x000 uuuu uuuu 0x0x x000 0x0x x000 uuuu uuuu 0x0x x000 0x0x x000 misc 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 endpt_en 0000 0111 uuuu uuuu 0000 0111 0000 0111 uuuu uuuu 0000 0111 0000 0111 fifo0 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0000 0000 0000 fifo1 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0000 0000 0000 fifo2 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0000 0000 0000 usc 11xx 0000 uuxx uuuu 11xx 0000 11xx 0000 uuxx uuuu uu00 0u00 uu00 0u00 usr 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu u1uu 0000 u1uu 0000 scc 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu 0uu0 u000 0uu0 u000 spir ---- 0000 ---- 0000 ---- 0000 ---- 0000 ---- uuuu ---- 0000 ---- 0000 sbcr 0110 0000 0110 0000 0110 0000 0110 0000 uuuu uuuu 0110 0000 0110 0000 sbdr xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu xxxx xxxx xxxx xxxx note: "*" means "warm reset" "-" not implemented "u" means "unchanged" "x" means "unknown"
rev. 1.00 44 october 27, 2011 rev. 1.00 45 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface oscillator the clock source for these devices is provided by an integrated oscillator requiring no external components. this oscillator has two fxed frequencies of either 6mhz or 12mhz, the selection of which is made by the sysclk bit in the scc register. watchdog timer oscillator the wdt oscillator is a fully self-contained free running on-chip rc oscillator with a typical period of 32s at 5v requiring no external components. when the device enters the power down mode, the system clock will stop running but the wdt oscillator continues to free-run and to keep the watchdog active. however, to preserve power in certain applications the wdt oscillator can be disabled via a confguration option. power down mode and wake-up power down mode all of the holtek microcontrollers have the ability to enter a power down mode. when the device enters this mode, the normal operating current, will be reduced to an extremely low standby current level. this occurs because when the device enters the power down mode, the system oscillator is stopped which reduces the power consumption to extremely low levels, however, as the device maintains its present internal condition, it can be woken up at a later stage and continue running, without requiring a full reset. this feature is extremely important in application areas where the microcontroller must have its power supply constantly maintained to keep the device in a known condition but where the power supply capacity is limited such as in battery applications. entering the power down mode there is only one way for the device to enter the power down mode and that is to execute the "halt" instruction in the application program. when this instruction is executed, the following will occur: ? the system oscillator will stop running and the application program will stop at the "halt" instruction. ? the data memory contents and registers will maintain their present condition. ? the wdt will be cleared and resume counting if the wdt clock source is selected to come from the wdt or rtc oscillator. the wdt will stop if its clock source originates from the system clock. ? the i/o ports will maintain their present condition. ? in the status register, the power down fag, pdf, will be set and the watchdog time-out fag, to, will be cleared.
rev. 1.00 44 october 27, 2011 rev. 1.00 45 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface standby current considerations as the main reason for entering the power down mode is to keep the current consumption of the microcontroller to as low a value as possible, perhaps only in the order of several micro-amps, there are other considerations which must also be taken into account by the circuit designer if the power consumption is to be minimised. special attention must be made to the i/o pins on the device. all high-impedance input pins must be connected to either a fixed high or low level as any floating input pins could create internal oscillations and result in increased current consumption. care must also be taken with the loads, which are connected to i/o pins, which are setup as outputs. these should be placed in a condition in which minimum current is drawn or connected only to external circuits that do not draw current, such as other cmos inputs. if the configuration options have enabled the watchdog timer internal oscillator then this will continue to run when in the power down mode and will thus consume some power. for power sensitive applications it may be therefore preferable to use the system clock source for the watchdog timer. wake-up after the system enters the power down mode, it can be woken up from one of various sources listed as follows: ? an external reset ? an external falling edge wake-up ? a system interrupt ? a wdt overfow if the system is woken up by an external reset, the device will experience a full system reset, however, if the device is woken up by a wdt overfow, a watchdog timer reset will be initiated. although both of these wake-up methods will initiate a reset operation, the actual source of the wake-up can be determined by examining the to and pdf flags. the pdf flag is cleared by a system power-up or executing the clear watchdog timer instructions and is set when executing the "halt" instruction. the to fag is set if a wdt time-out occurs, and causes a wake-up that only resets the program counter and stack pointer, the other fags remain in their original status. each pin can be setup via an individual confguration option to permit a negative transition on the pin to wake-up the system. when a pin wake-up occurs, the program will resume execution at the instruction following the "halt" instruction. if the system is woken up by an interrupt, then two possible situations may occur. the frst is where the related interrupt is disabled or the interrupt is enabled but the stack is full, in which case the program will resume execution at the instruction following the "halt" instruction. in this situation, the interrupt which woke-up the device will not be immediately serviced, but will rather be serviced later when the related interrupt is finally enabled or when a stack level becomes free. the other situation is where the related interrupt is enabled and the stack is not full, in which case the regular interrupt response takes place. if an interrupt request fag is set to "1" before entering the power down mode, the wake-up function of the related interrupt will be disabled. no matter what the source of the wake-up event is, once a wake-up situation occurs, a time period equal to 1024 system clock periods will be required before normal system operation resumes. however, if the wake-up has originated due to an interrupt, the actual interrupt subroutine execution will be delayed by an additional one or more cycles. if the wake-up results in the execution of the next instruction following the "halt" instruction, this will be executed immediately after the 1024 system clock period delay has ended.
rev. 1.00 46 october 27, 2011 rev. 1.00 47 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface watchdog timer the wdt clock source is implemented by a dedicated rc oscillator (wdt oscillator) or instruction clock (system clock divided by 4), enabled using a confguration option. this timer is designed to prevent a software malfunction or sequence jumping to an unknown location with unpredictable results. if the watchdog timer is disabled, all the executions related to the wdt results in no operation. once the internal wdt oscillator (rc oscillator normally with a period of 32s) is selected, it is frst divided by 256 (8-stages) to get the nominal time-out period of approximately 8.19ms. this time-out period may vary with temperature, v dd and process variations. by using the wdt prescaler, longer time-out periods can be realized. writing data to ws2, ws1, ws0 (bit 2, 1, 0 of the wdts) can give different time-out periods. if ws2, ws1, ws0 are all equal to "1", the division ratio is up to 1:128, and the maximum time-out period is 1.048s. if the wdt oscillator is disabled, the wdt clock source may still come from the instruction clock and operate in the same manner except that in the power down mode state the wdt may stop counting and lose its protecting purpose. in this situation the wdt logic can be restarted by external logic. the high nibble and bit 3 of the wdts are reserved for user defned fags, which can be used to indicate some specifed status. if the device operates in a noisy environment, using the on-chip rc oscillator (wdt osc) is strongly recommended, since the halt will stop the system clock.               
              ??       ?      
   ? ?  ? - 
   ??   ? ?   ?
- ? ?   ?
-    ?      ? ? ? ? ? ? ??   ? 
      ?      ? - 
   ??   watchdog timer wdts register bit 7 6 5 4 3 2 1 0 name ws7 D D D ws3 ws2 ws1 ws0 r/w r/w D D D r/w r/w r/w r/w por 1 0 0 0 0 1 1 1 bit 7 ws7: usb reset enable control bit described elsewhere bit 6~4 unimplemented, read as 0 bit 3 ws3: d+, and d- have a 300k 50% ohm pull-high control bit described elsewhere bit 2~0 ws2, ws1, ws0: wdt time-out period selection 000: 1:1 001: 1:2 010: 1:4 011: 1:8 100: 1:16 101: 1:32 110: 1:64 111: 1:128
rev. 1.00 46 october 27, 2011 rev. 1.00 47 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface usb interface suspend wake-up and remote wake-up if there is no signal on the usb bus for over 3ms, the device will go into a suspend mode. the suspend line (bit 0 of the usc register) will be set to "1" and a usb interrupt is triggered to indicate that the devices should jump to the suspend state to meet the 500a usb suspend current spec. in order to meet the 500a suspend current, the frmware should disable the usb clock by clearing the usbcken bit which is bit 3 of the scc register to "0". the suspend current is 400a. the user can further decrease the suspend current to 250a by setting the susp2 bit which is bit 4 of the scc register. if in the usb mode set this bit lvr opt must disable. when the resume signal is sent out by the host, the devices will wake up the mcu with a usb interrupt and the resume line (bit 3 of the usc register) is set. in order to make the device function properly, the firmware must set the usbcken (bit 3 of the scc register) to "1" and clear the susp2 (bit 4 of the scc register). since the resume signal will be cleared before the idle signal is sent out by the host, the suspend line (bit 0 of the usc register) will be set to "0". so when the mcu is detecting the suspend line (bit 0 of usc register), the resume line condition should be noted and taken into consideration. after finishing the resume signal, the suspend line will go inactive and a usb interrupt will be triggered. the following is the timing diagram.                as the device has a remote wake up function it can wake-up the usb host by sending a wake-up pulse through rmot_wk (bit 1 of the usc register). once the usb host receives a wake-up signal from the devices, it will send a resume signal to the device. the timing is as follows:                
 
      
    
rev. 1.00 48 october 27, 2011 rev. 1.00 49 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface to confgure as ps2 device the devices can also be configured as a usb interface or ps2 interface device, by configuring mode_ctrl0 (bit 4 of the usr register) and mode_ctrl1 (bit 5 of the usr register). if mode_ctrl0=1, and mode_ctrl1=0, the device will be confgured as a ps2 interface, pin udn is confgured as a ps2 data pin and udp is confgured as a ps2 clk pin. the user can read or write to the ps2 data or ps2 clk pin by accessing the corresponding bit ps2_dai (bit 4 of the usc register), ps2_cki (bit 5 of the usc register), ps2_dao (bit 6 of the usc register) and ps2_cko (bit 7 of the usc register) respectively. the user should make sure that in order to read the data properly, the corresponding output bit must be set to 1. for example, if it is desired to read the ps2 data by reading ps2_dai, then ps2_dao should set to 1. otherwise it is always read as 0. if mode_ctrl0=0, and mode_ctrl1=1, the device is confgured as a usb interface. both the udn and udp are driven by the sie of the devices. the user can only write or read the usb data through the corresponding fifo. both the mode_ctrl0 and mode_ctrl1 default is 0. usb control registers there are twelve registers used for the usb function. the awr register contains the current address and a remote wake up function control bit. the initial value of awr is "00h". the address value extracted from the usb command is not to be loaded into this register until the setup stage is completed. awr register bit 7 6 5 4 3 2 1 0 name ad6 ad5 ad4 ad3 ad2 ad1 ad0 wken r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7~1 ad6~ad0: usb device address bit 0 wken: usb remote-wake-up control bit 0: disable 1: enable the awr register contains the current address and a remote wake up function control bit. the initial value of awr is 00h. the address value extracted from the usb command has not to be loaded into this register until the setup stage has fnished. wdts register bit 7 6 5 4 3 2 1 0 name ws7 ws3 ws2 ws1 ws0 r/w r/w r/w r/w r/w r/w por 1 0 0 0 0 1 1 1 bit 7 ws7: usb reset enable control bit 0: usb reset signal cannot reset mcu 1: usb reset signal can reset mcu and set urst_flag (bit 2 of the usc register) (default on at mcu reset) bit 6~4 unimplemented, read as 0 bit 3 ws3: d+, and d- have a 300k 50% ohm pull-high control bit 0: non-pull-high (default) 1: pull-high bit 2~0 ws2, ws1, ws0: wdt time-out period selection described elsewhere
rev. 1.00 48 october 27, 2011 rev. 1.00 49 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface usc register bit 7 6 5 4 3 2 1 0 name ps2_cko ps2_dao ps2_cki ps2_dai resume_o urst_flag rmot_wk suspend r/w w w r r r r/w w r por 1 1 0 0 0 0 0 0 bit 7 ps2_cko: output for driving udp/clk pin, when the device works under 3d ps2 mouse function. the default value is 1. bit 6 ps2_dao: output for driving udn/data pin, when the device works under 3d ps2 mouse function. the default value is 1. bit 5 ps2_cki: udp/clk input detect bit 0: input 0 1: input 1 bit 4 ps2_dai: udn/data input detect bit 0: input 0 1: input 1 bit 3 resume_o: usb resume indication bit 0: suspend bit goes to 0 1: leave the suspend mode when the usb leaves the suspend mode, this bit is set to 1 (set by sie). when the resume is set by sie, an interrupt will be generated to wake-up the mcu. in order to detect the suspend state, the mcu should set usbcken and clear susp2 (in the scc register) to enable the sie detect function. resume will be cleared when the suspend goes to 0. when the mcu is detecting the suspend, the condition of resume (causes the mcu to wake-up) should be noted and taken into consideration. bit 2 urst_flag: usb reset indication bit 0: no usb reset 1: usb reset occurred this bit is set/cleared by the usb sie. this bit is used to detect a usb reset event on the usb bus. when this bit is set to 1, this indicates that a usb reset has occurred and that a usb interrupt will be initialized. bit 1 rmot_wk: usb remote wake-up command 0: no remote wake-up 1: remote wake-up it is set by mcu to leave the usb host leaving the suspend mode. indicate that the usb host leaves the suspend mode. bit 0 suspend: usb suspend indication 0: not in the suspend mode 1: enter the suspend mode when this bit is set to 1 (set by sie), it indicates that the usb bus has entered the suspend mode. the usb interrupt is also triggered when this bit changes from low to high.
rev. 1.00 50 october 27, 2011 rev. 1.00 51 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface the usr (usb endpoint interrupt status register) register is used to indicate which endpoint is accessed and to select the serial bus, ps2 or usb. the endpoint request fags, ep0_int, ep1_int and ep2_int, are used to indicate which endpoints are accessed. if an endpoint is accessed, the related endpoint request fag will be set to 1 and the usb interrupt will occur, if the usb interrupt is enabled and the stack is not full. when the active endpoint request fag is served, the endpoint request fag has to be cleared to 0. usr register bit 7 6 5 4 3 2 1 0 name usb_fag D mode_ctrl1 mode_ctrl0 D ep2_int ep1_int ep0_int r/w r/w D r/w r/w D r/w r/w r/w por 0 D 0 0 D 0 0 0 bit 7 usb_fag: usb mode indication fag 0: not in usb mode 1: in usb mode this fag is used to indicate the mcu is in usb mode or not. this bit will be cleared to 0 after power-on reset. the default value is 0. bit 6 unimplemented bit 5~4 mode_ctrl1, mode_ctrl0: usb mode control bits 00: non-usb mode, turn-off v33o, both udp and udn can be read and write (default) 01: non-usb mode, has 200 between vdd and v33o, both udp and udn can be read and write 10: usb mode, 1.5k between udn and v33o, v33o output 3.3v, both udp and udn are read only 11: non-usb mode, v33o output 3.3v, both udp and udn can be read and write bit 3 unimplemented bit 2 ep2_int: endpoint 2 accessed detection 0: not accessed 1: accessed bit 1 ep1_int: endpoint 1 accessed detection 0: not accessed 1: accessed bit 0 ep0_int: endpoint 0 accessed detection 0: not accessed 1: accessed when the ep0_int, ep1_int, or ep2_int bit is set to 1 (set by the sie), it indicates that endpoint 0, 1, or 2, is accessed and a usb interrupt will occur. when the interrupt has been served, this bit should be cleared by frmware.
rev. 1.00 50 october 27, 2011 rev. 1.00 51 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface there is a system clock control register implement to select the clock used in the mcu. this register consisters of the usb clock sontrol bit, usbcken, second suspend mode control bit, susp2, and a system colck selection bit, sysclk. the ps2 mode indicate bit, ps2_fag, and a system clock adjust control bit, clk_adj. scc register bit 7 6 5 4 3 2 1 0 name clk_adj sysclk ps2_fag susp2 usbcken D D D r/w r/w r/w r/w r/w r/w D D D por 0 0 0 0 0 D D D bit 7 clk_adj: usb mode system clock adjustment 0: enable (default) 1: disable this bit is used to adjust the system clock for the usb mode for temperature changes. in the power-down mode this bit should be set high to reduce power consumption. bit 6 sysclk: specify mcu oscillator frequency indication bit 0: 12mhz crystal oscillator or resonator, clear this bit to 0 1: 6mhz crystal oscillator or resonator, set this bit to 1 this bit is used to specify the system oscillator frequency used by the mcu. if an integrated 6mhz oscillator is used, this bit should be set to 1. if an integrated 12mhz oscillator is used, this bit should be cleared to 0 (default). bit 5 ps2_fag: ps2 mode indication bit 0: not ps2 mode 1: ps2 mode this fag is used to indicate that the mcu is in the ps2 mode. (bit=1) this bit is r/w by fw and will be cleared to 0 after power-on reset. (default="0") bit 4 susp2: reduce power consumption in suspend mode control bit 0: in normal mode 1: in halt mode, set this bit to 1 for reducing power consumption bit 3 usbcken: usb clock control bit 0: disable 1: enable bit 2~0 unimplemented stall and pipe, pipe_ctrl, endpt_en registers the pipe register represents whether the corresponding endpoint is accessed by the host or not. after an act_en signal has been sent out, the mcu can check which endpoint had been accessed. this register is set only after the a time when the host is accessing the corresponding endpoint. the stall register shows whether the corresponding endpoint works or not. as soon as the endpoint works improperly, the corresponding bit must be set. the pipe_ctrl register is used for confguring the in (bit=1) or out (bit=0) pipe. the default is defne in pipe. bit 0 (data0) of the pipe_ctrl register is used to set the data toggle of any endpoint (except endpoint 0) using data toggles to the value data0. once the user wants any endpoint (except endpoint 0) using data toggles to the value data0. the user can output a low pulse to this bit. the low pulse period must at least 10 instruction cycles. the endpt_en register is used to enable or disable the corresponding endpoint (except endpoint 0) enable endpoint (bit=1) or disable endpoint (bit=0)
rev. 1.00 52 october 27, 2011 rev. 1.00 53 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface pipe_ctrl register bit 7 6 5 4 3 2 1 0 name D D D D D setio2 setio1 data0 r/w D D D D D r/w r/w r/w por D D D D D 1 1 1 bit 7~3 unimplemented bit 2 setio2: usb pipe 2 in or out control bit 0: out 1: in (default) bit 1 setio1: usb pipe 1 in or out control bit 0: out 1: in (default) bit 0 data0: usb endpoint data control bit 0: low 1: high stall register bit 7 6 5 4 3 2 1 0 name D D D D D stl2 stl1 stl0 r/w D D D D D r/w r/w r/w por D D D D D 1 1 1 bit 7~3 unimplemented bit 2 stl2: usb endpoint 2 stall indication bit 0: not stall 1: stall bit 1 stl1: usb endpoint 1 stall indication bit 0: not stall 1: stall bit 0 stl0: usb endpoint 0 stall indication bit 0: not stall 1: stall pipe register bit 7 6 5 4 3 2 1 0 name D D D D D pipe2 pipe1 pipe0 r/w D D D D D r r r por D D D D D 0 0 0 bit 7~3 unimplemented bit 2 pipe2: usb pipe 2 in use indication bit 0: not in use 1: in use bit 1 pipe1: usb pipe 1 in use indication bit 0: not in use 1: in use bit 0 pipe0: usb pipe 0 in use indication bit 0: not in use 1: in use
rev. 1.00 52 october 27, 2011 rev. 1.00 53 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface endpt_en register bit 7 6 5 4 3 2 1 0 name D D D D D ep2en ep1en ep0en r/w D D D D D r/w r/w r/w por D D D D D 1 1 1 bit 7~3 unimplemented bit 2 ep2en: usb endpoint 2 control bit 0: disable 1: enable bit 1 ep1en: usb endpoint 1 control bit 0: disable 1: enable bit 0 ep0en: usb endpoint 0 control bit 0: disable 1: enable usb_stat register bit 7 6 5 4 3 2 1 0 name D D D se1 se0 k_state j_state eop r/w D D D r/w r/w r/w r/w r/w por D D D x x x x x bit 7~5 unimplemented bit 4 se1: usb se1 noise indication bit 0: no noise 1: noise this bit is used to indicate the sie has detected a se1 noise in the usb bus. this bit is set by sie and cleared by f/w. bit 3 se0: usb se0 noise indication bit 0: no noise 1: noise this bit is used to indicate the sie has detected a se0 noise in the usb bus. this bit is set by sie and cleared by f/w. bit 2 k_state: usb sie k_state indication bit 0: not k_state 1: k_state this bit is used to indicate the sie has detected a k_state usb signal in the usb bus. this bit is set by sie and cleared by f/w. bit 1 j_state: usb sie j_state indication bit 0: not j_state 1: j_state this bit is used to indicate the sie has detected a j_state usb signal in the usb bus. this bit is set by sie and cleared by f/w. bit 0 eop: usb eop indication bit 0: not eop 1: eop this bit is used to indicate the sie has detected an eop usb signal in the usb bus. this bit is set by sie and cleared by f/w. the usb_stat register is used to indicate the present usb signal state.
rev. 1.00 54 october 27, 2011 rev. 1.00 55 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface sies register bit 7 6 5 4 3 2 1 0 name nmi D D D D D f0_err adr_set r/w r/w D D D D D r/w r/w por 0 D D D D D 0 0 bit 7 nmi: nak token interrupt mask fag 0: always has usb interrupt if the usb accesses fifo0 1: has only usb interrupt, data is transmitted to the pc host or data is received from the pc host this bit is used to control whether the usb interrupt is output to the mcu in a nak response to the pc host in or out token, only for endpoint0. bit 6~2 unimplemented bit 1 f0_err: fifo accessed error indicator 0: no error 1: error this bit is used to indicate that some errors have occurred when the fifo is accessed. this bit is set by sie and should be cleared by frmware. bit 0 adr_set: device address updated method control bit 0: update address after an written address to the awr register 1: update address after pc host read out data this bit is used to confgure the sie to automatically change the device address with the value of the address+remote_wake-up register. when this bit is set to 1 by f/w, the sie will update the device address with the value of the address+remote_wake-up register after the pc host has successfully read the data from the device by the in operation. the sie will clear the bit after updating the device address. otherwise, when this bit is cleared to 0, the sie will update the device address immediately after an address is written to the address+remote_wake-up register. default 0.
rev. 1.00 54 october 27, 2011 rev. 1.00 55 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface misc register bit 7 6 5 4 3 2 1 0 name len0 ready scmd selp1 selp0 clear tx req r/w r r r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7 len0: 0-sized packet indication fag 0: not 0-sized packet 1: 0-sized packet this bit is used to indicate that a 0-sized packet has been sent from a host to the mcu. this bit should be cleared by frmware. bit 6 ready: desired fifo ready indication fag 0: not ready 1: ready this bit is used to indicate that the desired endpoint fifo is ready for operation. bit 5 scmd: setup command indication fag 0: not setup command 1: setup command this bit is used to show that the data in the endpoint fifo is a setup command. this bit has to be cleared by frmware. that is to say, even if the mcu is busy, the device will not miss any setup commands from the host. bit 4~3 selp1, selp0: endpoint fifo selection bits 00: endpoint fifo0 01: endpoint fifo1 10: endpoint fifo2 11: reserved bit 2 clear: clear fifo function control bit 0: disable 1: enable this bit is used to clear the fifo, even if the fifo is not ready. bit 1 tx: data writing to fifo status indication fag 0: data writing fnished 1: data writing to fifo this bit defines the direction of data transferring between the mcu and endpoint fifo. when the tx is set to 1, this means that the mcu wants to write data to the endpoint fifo. after the task is completed, this bit must be cleared to 0 before terminating the request to represent the end of transferring. for a read action, this bit has to be cleared to 0 to represent that mcu wants to read data from the endpoint fifo and has to be set to 1 after completion. bit 0 request: desired fifo request status indication fag 0: no request 1: request after setting the other status of the desired one in the misc, endpoint fifo can be requested by setting this bit to 1. after the task is completed, this bit must be cleared to 0.
rev. 1.00 56 october 27, 2011 rev. 1.00 57 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface the mcu can communicate with the endpoint fifo by setting the corresponding registers, of which the address is listed in the following table. after reading the current data, the next data will show after 2s, this is used to check the endpoint fifo status and response to the misc register, if read/write action is still going on. registers r/w bank address bit7~bit0 fifo0 r/w 1 48h data7~data0 fifo1 r/w 1 49h data7~data0 fifo2 r/w 1 4ah data7~data0 there are some timing constrains and usages illustrated here. by setting the misc register, the mcu can perform reading, writing and clearing actions. there are some examples shown in the following table for endpoin fifo reading, writing and clearing. actions misc setting flow and status read fifo0 sequence 00h01hdelay 2s, check 41hread* from fifo0 register and check not ready (01h) 03h02h write fifo1 sequence 0ah0bhdelay 2s, check 4bhwrite* to fifo1 register and check not ready (0bh) 09h08h check whether fifo0 can be read or not 00h01hdelay 2s, check 41h (read) or 01h (not ready) 00h check whether fifo1 can be written or not 0ah0bhdelay 2s, check 4bh (read) or 0bh (not ready) 0ah read 0-sized packet sequence from fifo0 00h01hdelay 2s, check 81hread once (01h)03hs02h write 0-sized packet sequence to fifo1 0ah0bhdelay 2s, check 4bh09h08h note: *: there is a 2s time between 2 read actions or between 2 write actions.
rev. 1.00 56 october 27, 2011 rev. 1.00 57 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface serial interface C spi the spi interface is often used to communicate with external peripheral devices such as sensors, flash or eeprom memory devices etc.. originally developed by motorola, the four line spi interface is a synchronous serial data interface that has a relatively simple communication protocol simplifying the programming requirements when communicating with external hardware devices. the communication is full duplex and operates as a slave/master type, where the device can be either master or slave. although the spi interface specifcation can control multiple slave devices from a single master, however this device is provided with only one scs pin. if the master needs to control multiple slave devices from a single master, the master can use i/o pins to select the slave devices. spi interface operation the spi interface is a full duplex synchronous serial data link. it is a four line interface with pin names sdi, sdo, sck and scs . pins sdi and sdo are the serial data input and serial data output lines, sck is the serial clock line and scs is the slave select line. as the spi interface pins are pin-shared with normal i/o pins, the spi interface must frst be enabled by setting the correct bits in the sbcr and spir registers. the spi can be disabled or enabled using the spi_en bit in the spir register. communication between devices connected to the spi interface is carried out in a slave/master mode with all data transfer initiations being implemented by the master. the master also controls the clock signal. as the device only contains a single scs pin only one slave device can be utilized. the scs pin is controlled by the application program, set the csen bit to 1 to enable the scs pin function and clear the csen bit to 0 to place the scs pin into a foating state.                         spi master/slave connection                    
                 ?   
   
      
     ?   ?         ?
?     ? -   ? ?  ??   -  ?   -  spi block diagram
rev. 1.00 58 october 27, 2011 rev. 1.00 59 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface the spi function in this device offers the following features: ? full duplex synchronous data transfer ? both master and slave modes ? lsb frst or msb frst data transmission modes ? transmission complete fag ? rising or falling active clock edge the status of the spi interface pins is determined by a number of factors such as whether the device is in the master or slave mode and upon the condition of certain control bits such as spi_csen and spi_en. spi registers there are three internal registers which control the overall operation of the spi interface. these are the sbdr data register and two registers spir and sbcr. register name bit 7 6 5 4 3 2 1 0 spir D D D D spi_en spi_csen spi_mode spi_cpol sbcr cks m1 m0 sben mls csen wcol trf sbdr d7 d6 d5 d4 d3 d2 d1 d0 the sbdr register is used to store the data being transmitted and received. before the device writes data to the spi bus, the actual data to be transmitted must be placed in the sbdr register. after the data is received from the spi bus, the device can read it from the sbdr register. any transmission or reception of data from the spi bus must be made via the sbdr register. sbdr register bit 7 6 5 4 3 2 1 0 name d7 d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w rw por x x x x x x x x bit 7~0 d7~d0: spi data bits note that data written to the sbdr register will only be written to the txrx buffer, whereas data read from the sbdr register will actual be read from the register. there are also two control registers for the spi interface, spir and sbcr. register spir is used to control the enable/disable function and to set the spi clock active edge type. register sbcr is used for other control functions such as lsb/msb selection, write collision fag, data transmission clock frequency selection etc..
rev. 1.00 58 october 27, 2011 rev. 1.00 59 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface spir register bit 7 6 5 4 3 2 1 0 name D D D D spi_en spi_csen spi_mode spi_cpol r/w D D D D r/w r/w r/w r/w por D D D D 0 0 0 0 bit 7~4 unimplemented bit 3 spi_en: spi interface pins control 0: i/o mode (default) 1: spi mode bit 2 spi_csen: spi software bit csen function control 0: disable. the csen bit has no effect on the scs pin and the scs pin is used as an i/o pin 1: enable. the csen bit is used as the enable/disable control for the scs pin bit 1 spi_mode: determines spi clock sck active clock edge type spi_cpol=0 0: sck is high base level and data capture at sck rising edge 1: sck is high base level and data capture at sck falling edge spi_cpol=1 0: sck is low base level and data capture at sck falling edge 1: sck is low base level and data capture at sck rising edge the spi_mode and spi_cpol bits are used to setup the way that the clock signal outputs and inputs data on the spi bus. these two bits must be configured before data transfer is executed otherwise an erroneous clock edge may be generated. the spi_cpol bit determines the base condition of the clock line. if the bit is high, then the sck line will be low when the clock is inactive. when the spi_cpol bit is low, then the sck line will be high when the clock is inactive. the spi_mode bit determines active clock edge type which depends upon the condition of spi_cpol bit. bit 0 spi_cpol: determines the base condition of the spi clock line sck 0: the sck line will be high when the spi clock is inactive 1: the sck line will be low when the spi clock is inactive the spi_cpol bit determines the base condition of the spi clock line, if the bit is high, then the sck line will be low when the clock is inactive. when the spi_cpol bit is low, then the sck line will be high when the clock is inactive.
rev. 1.00 60 october 27, 2011 rev. 1.00 61 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface sbcr register bit 7 6 5 4 3 2 1 0 name cks m1 m0 sben mls csen wcol trf r/w r/w r/w r/w r/w r/w r/w r/w rw por 0 1 1 0 0 0 0 0 bit 7 cks: spi clock f spi source selection 0: f spi =f sys /2 1: f spi =f sys bit 6~5 m1~m0: spi operating mode and baud rate control bits 00: spi master mode; spi clock is f spi 01: spi master mode; spi clock is f spi /4 10: spi master mode; spi clock is f spi /16 11: spi slave mode this bit can be read or written by user software program. bit 4 sben: spi serial bus enable control 0: disable 1: enable the bit is the overall on/off control for the spi serial bus. when the sben bit is cleared to zero to disable the spi interface, the sdi, sdo, sck and scs lines will be in a foating condition and the spi operating current will be reduced to a minimum value. when the bit is high, the spi interface is enabled. bit 3 mls: spi data shift order 0: lsb shift frst 1: msb shift frst this is the data shift select bit and is used to select how the data is transferred, either msb or lsb frst. setting the bit high will select msb frst and low for lsb frst. bit 2 csen: spi scs pin control 0: disable, other functions 1: enable the csen bit is used as an enable/disable for the scs pin. if this bit is low, then the scs pin will be disabled and placed into a foating condition. if the bit is high the scs pin will be enabled and used as a select pin. note that using the csen bit can be disabled or enabled by the csen control bit named spi_csen in the spir register. bit 1 wcol: spi write collision fag 0: collision free 1: collision detected the wcol fag is used to detect if a data collision has occurred. if this bit is high it means that data has been attempted to be written to the sbdr register during a data transfer operation. this writing operation will be ignored if data is being transferred. the bit can be cleared by the application program. bit 0 trf: spi transmit/receive complete fag 0: not complete 1: transmission/reception complete the trf bit is the transmit/receive complete fag and is set to 1 automatically when an spi data transmission is completed, but must be set to 0 by the application program. it can be used to generate an interrupt.
rev. 1.00 60 october 27, 2011 rev. 1.00 61 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface spi communication after the spi interface is enabled by setting the spi_en bit high, then in the master mode, when data is written to the sbdr register, transmission/reception will begin simultaneously. when the data transfer is complete, the trf flag will be set automatically, but must be cleared using the application program. in the slave mode, when the clock signal from the master has been received, any data in the sbdr register will be transmitted and any data on the sdi pin will be shifted into the sbdr register. the master should output an scs signal to enable the slave device before a clock signal is provided. the slave data to be transferred should be well prepared at the appropriate moment relative to the scs signal depending upon the options of the spi_mode bit and spi_cpol bit. the accompanying timing diagram shows the relationship between the slave data and scs signal for various confgurations of the spi_mode and spi_cpol bits. the spi will continue to function even in the idle mode.
rev. 1.00 62 october 27, 2011 rev. 1.00 63 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface d 7 / d 0 d 6 / d 1 d 5 / d 2 d 4 / d 3 d 3 / d 4 d 2 / d 5 d 1 / d 6 d 0 / d 7 d 7 / d 0 d 6 / d 1 d 5 / d 2 d 4 / d 3 d 3 / d 4 d 2 / d 5 d 1 / d 6 d 0 / d 7 spi master mode timing sdi data capture d 7 / d 0 d 6 / d 1 d 5 / d 2 d 4 / d 3 d 3 / d 4 d 2 / d 5 d 1 / d 6 d 0 / d 7 spi slave mode timing ( spi _ mode= 0 ) sdi data capture d 7 / d 0 d 6 / d 1 d 5 / d 2 d 4 / d 3 d 3 / d 4 d 2 / d 5 d 1 / d 6 d 0 / d 7 ( sdo change as soon as writing occur ; sdo = floating if scs = 1 ) sdi data capture scs sben , csen = 1 write to sbdr sck ( spi _ cpol = 1 spi _ mode = 0 ) sdo sck sck sdo scs sck ( ) sck ( ) sck ( ) sdo write to sbdr write to sbdr sck sck sdo scs sben = 1 , csen = 0 ( external pull - high ) spi _ cpol = 0 spi _ mode = 0 spi _ cpol = 1 spi _ mode = 1 spi _ cpol = 0 spi _ mode = 1 spi _ mode = 0 spi _ mode = 1 spi slave mode timing ( spi _ mode = 1 ) note : for spi slave mode , if sben = 1 and csen = 0 , spi is always enabled and ignore the scs level ( ( ) ) ( sdo not change until first sck edge ) ( spi _ cpol = 1 ) ( spi _ cpol = 0 ) ( spi _ cpol = 1 ) ( ) spi _ cpol = 0
rev. 1.00 62 october 27, 2011 rev. 1.00 63 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface sben = 1 write data into sbdr wcol = 1 ? clear wcol y transmission completed ? ( trf = 1 ? ) n y read data from sbdr clear trf transfer finished ? n y end master or slave master slave a a spi transfer configure csen and mls m 1 m 0 = 11 m 1 m 0 = 00 , 01 , 10 setup cks f spi = fsys / 1 , / 2 spi transfer control flowchart spi bus enable/disable to enable the spi bus, set sben =1, csen = 1 and scs =0, then wait for data to be written into the sbdr (txrx buffer) register. for the master mode, after data has been written to the sbdr (txrx buffer) register, then transmission or reception will start automatically. when all the data has been transferred the trf bit should be set. for the slave mode, when clock pulses are received on sck, data in the txrx buffer will be shifted out or data on sdi will be shifted in. to disable the spi bus sck, sdi, sdo, scs should be in a foating condition.
rev. 1.00 64 october 27, 2011 rev. 1.00 65 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface spi operation all communication is carried out using the 4-line interface for either master or slave mode. the csen bit in the sbcr register controls the overall function of the spi interface. setting this bit high will enable the spi interface by allowing the scs line to be active, which can then be used to control the spi interface. if the csen bit is low, the spi interface will be disabled and the scs line will be in a floating condition and can therefore not be used for control of the spi interface. the sben bit in the sbcr register must also be high which will place the sdi line in a foating condition and the sdo line high. if in master mode the sck line will be either high or low depending upon the clock polarity selection bit spi_cpol in the spir register. if in slave mode the sck line will be in a foating condition. if sben is low then the bus will be disabled and scs , sdi, sdo and sck will all be in a foating condition. in the master mode the master will always generate the clock signal. the clock and data transmission will be initiated after data has been written into the sbdr register. in the slave mode, the clock signal will be received from an external master device for both data transmission and reception. the following sequences show the order to be followed for data transfer in both master and slave mode: master mode: ? step 1 select the clock source using the cks bit in the sbcr control register ? step 2 setup the m0 and m1 bits in the sbcr control register to select the master mode and the required baud rate. values of 00, 01 or 10 can be selected. ? step 3 setup the csen bit and setup the mls bit to choose if the data is msb or lsb frst, this must be same as the slave device. ? step 4 setup the sben bit in the sbcr control register to enable the spi interface. ? step 5 for write operations: write the data to the sbdr register, which will actually place the data into the txrx buffer. then use the sck and scs lines to output the data. after this go to step6. for read operations: the data transferred in on the sdi line will be stored in the txrx buffer until all the data has been received at which point it will be latched into the sbdr register. ? step 6 check the wcol bit if set high then a collision error has occurred so return to step5. if equal to zero then go to the following step. ? step 7 check the trf bit or wait for a spi serial bus interrupt. ? step 8 read data from the sbdr register. ? step 9 clear trf. ? step10 go to step 5.
rev. 1.00 64 october 27, 2011 rev. 1.00 65 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface slave mode: ? step 1 the cks bit has a dont care value in the slave mode. ? step 2 setup the m0 and m1 bits in the sbcr control register to 11 to select the slave mode. the cks bit is dont care. ? step 3 setup the csen bit and setup the mls bit to choose if the data is msb or lsb frst, this must be same as the master device. ? step 4 setup the sben bit in the sbcr control register to enable the spi interface. ? step 5 for write operations: write the data to the sbdr register, which will actually place the data into the txrx buffer. then wait for the master clock sck and scs signal. after this go to step6. for read operations: the data transferred in on the sdi line will be stored in the txrx buffer until all the data has been received at which point it will be latched into the sbdr register. ? step 6 check the wcol bit if set high then a collision error has occurred so return to step5. if equal to zero then go to the following step. ? step 7 check the trf bit or wait for a spi serial bus interrupt. ? step 8 read data from the sbdr register. ? step 9 clear trf. ? step10 go to step 5. error detection the wcol bit in the sbcr register is provided to indicate errors during data transfer. the bit is set by the spi serial interface but must be cleared by the application program. this bit indicates a data collision has occurred which happens if a write to the sbdr register takes place during a data transfer operation and will prevent the write operation from continuing.
rev. 1.00 66 october 27, 2011 rev. 1.00 67 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface confguration options no. options 1 pa0~7 pull-high by bit (default pull-high) 2 pb wake-up by nibble (default pull-high) 3 pb pull-high by nibble (default pull-high) 4 lvr enable/disable (default enable) 5 wdt function: enable, disable for normal mode (default enable) 6 wdt clock source: rc; f sys /4 (default t1) 7 clrwdt instruction is by 1 or 2 8 pa output mode (cmos/nmos/pmos) by bit (default cmos) 9 pa0~7 wake-up by bit (default enable) 10 tbhp enable/disable (default disable) 11 pe0, pe1 pull-high by bit 12 pe0, pe1, pe2 wake-up by bit 13 pa0~7 power source: vdd (default vdd)/v33o regulator output 14 pe2/ res pin option (default res pin) application circuit                     
                          note: the resistance and capacitance for the reset circuit should be designed in such a way as to ensure that the vdd is stable and remains within a valid operating voltage range before bringing res high.
rev. 1.00 66 october 27, 2011 rev. 1.00 67 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface instruction set introduction central to the successful operation of any microcontroller is its instruction set, which is a set of program instruction codes that directs the microcontroller to perform certain operations. in the case of holtek microcontrollers, a comprehensive and fexible set of over 60 instructions is provided to enable programmers to implement their application with the minimum of programming overheads. for easier understanding of the various instruction codes, they have been subdivided into several functional groupings. instruction timing most instructions are implemented within one instruction cycle. the exceptions to this are branch, call, or table read instructions where two instruction cycles are required. one instruction cycle is equal to 4 system clock cycles, therefore in the case of an 8mhz system oscillator, most instructions would be implemented within 0.5s and branch or call instructions would be implemented within 1s. although instructions which require one more cycle to implement are generally limited to the jmp, call, ret, reti and table read instructions, it is important to realize that any other instructions which involve manipulation of the program counter low register or pcl will also take one more cycle to implement. as instructions which change the contents of the pcl will imply a direct jump to that new address, one more cycle will be required. examples of such instructions would be clr pcl or mov pcl, a. for the case of skip instructions, it must be noted that if the result of the comparison involves a skip operation then this will also take one more cycle, if no skip is involved then only one cycle is required. moving and transferring data the transfer of data within the microcontroller program is one of the most frequently used operations. making use of three kinds of mov instructions, data can be transferred from registers to the accumulator and vice-versa as well as being able to move specifc immediate data directly into the accumulator. one of the most important data transfer applications is to receive data from the input ports and transfer data to the output ports. arithmetic operations the ability to perform certain arithmetic operations and data manipulation is a necessary feature of most microcontroller applications. within the holtek microcontroller instruction set are a range of add and subtract instruction mnemonics to enable the necessary arithmetic to be carried out. care must be taken to ensure correct handling of carry and borrow data when results exceed 255 for addition and less than 0 for subtraction. the increment and decrement instructions inc, inca, dec and deca provide a simple means of increasing or decreasing by a value of one of the values in the destination specifed.
rev. 1.00 68 october 27, 2011 rev. 1.00 69 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface logical and rotate operations the standard logical operations such as and, or, xor and cpl all have their own instruction within the holtek microcontroller instruction set. as with the case of most instructions involving data manipulation, data must pass through the accumulator which may involve additional programming steps. in all logical data operations, the zero flag may be set if the result of the operation is zero. another form of logical data manipulation comes from the rotate instructions such as rr, rl, rrc and rlc which provide a simple means of rotating one bit right or left. different rotate instructions exist depending on program requirements. rotate instructions are useful for serial port programming applications where data can be rotated from an internal register into the carry bit from where it can be examined and the necessary serial bit set high or low. another application where rotate data operations are used is to implement multiplication and division calculations. branches and control transfer program branching takes the form of either jumps to specifed locations using the jmp instruction or to a subroutine using the call instruction. they differ in the sense that in the case of a subroutine call, the program must return to the instruction immediately when the subroutine has been carried out. this is done by placing a return instruction ret in the subroutine which will cause the program to jump back to the address right after the call instruction. in the case of a jmp instruction, the program simply jumps to the desired location. there is no requirement to jump back to the original jumping off point as in the case of the call instruction. one special and extremely useful set of branch instructions are the conditional branches. here a decision is first made regarding the condition of a certain data memory or individual bits. depending upon the conditions, the program will continue with the next instruction or skip over it and jump to the following instruction. these instructions are the key to decision making and branching within the program perhaps determined by the condition of certain input switches or by the condition of internal data bits. bit operations the ability to provide single bit operations on data memory is an extremely fexible feature of all holtek microcontrollers. this feature is especially useful for output port bit programming where individual bits or port pins can be directly set high or low using either the set [m].i or clr [m].i instructions respectively. the feature removes the need for programmers to frst read the 8-bit output port, manipulate the input data to ensure that other bits are not changed and then output the port with the correct new data. this read-modify-write process is taken care of automatically when these bit operation instructions are used. table read operations data storage is normally implemented by using registers. however, when working with large amounts of fxed data, the volume involved often makes it inconvenient to store the fxed data in the data memory. to overcome this problem, holtek microcontrollers allow an area of program memory to be setup as a table where data can be directly stored. a set of easy to use instructions provides the means by which this fixed data can be referenced and retrieved from the program memory. other operations in addition to the above functional instructions, a range of other instructions also exist such as the halt instruction for power-down operations and instructions to control the operation of the watchdog timer for reliable program operations under extreme electric or electromagnetic environments. for their relevant operations, refer to the functional related sections.
rev. 1.00 68 october 27, 2011 rev. 1.00 69 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface instruction set summary the following table depicts a summary of the instruction set categorised according to function and can be consulted as a basic instruction reference using the following listed conventions. table conventions: x: bits immediate data m: data memory address a: accumulator i: 0~7 number of bits addr: program memory address mnemonic description cycles flag affected arithmetic add a,[m] add data memory to acc 1 z, c, ac, ov addm a,[m] add acc to data memory 1 note z, c, ac, ov add a,x add immediate data to acc 1 z, c, ac, ov adc a,[m] add data memory to acc with carry 1 z, c, ac, ov adcm a,[m] add acc to data memory with carry 1 note z, c, ac, ov sub a,x subtract immediate data from the acc 1 z, c, ac, ov sub a,[m] subtract data memory from acc 1 z, c, ac, ov subm a,[m] subtract data memory from acc with result in data memory 1 note z, c, ac, ov sbc a,[m] subtract data memory from acc with carry 1 z, c, ac, ov sbcm a,[m] subtract data memory from acc with carry, result in data memory 1 note z, c, ac, ov daa [m] decimal adjust acc for addition with result in data memory 1 note c logic operation and a,[m] logical and data memory to acc 1 z or a,[m] logical or data memory to acc 1 z xor a,[m] logical xor data memory to acc 1 z andm a,[m] logical and acc to data memory 1 note z orm a,[m] logical or acc to data memory 1 note z xorm a,[m] logical xor acc to data memory 1 note z and a,x logical and immediate data to acc 1 z or a,x logical or immediate data to acc 1 z xor a,x logical xor immediate data to acc 1 z cpl [m] complement data memory 1 note z cpla [m] complement data memory with result in acc 1 z increment & decrement inca [m] increment data memory with result in acc 1 z inc [m] increment data memory 1 note z deca [m] decrement data memory with result in acc 1 z dec [m] decrement data memory 1 note z rotate rra [m] rotate data memory right with result in acc 1 none rr [m] rotate data memory right 1 note none rrca [m] rotate data memory right through carry with result in acc 1 c rrc [m] rotate data memory right through carry 1 note c rla [m] rotate data memory left with result in acc 1 none rl [m] rotate data memory left 1 note none rlca [m] rotate data memory left through carry with result in acc 1 c rlc [m] rotate data memory left through carry 1 note c
rev. 1.00 70 october 27, 2011 rev. 1.00 71 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface mnemonic description cycles flag affected data move mov a,[m] move data memory to acc 1 none mov [m],a move acc to data memory 1 note none mov a,x move immediate data to acc 1 none bit operation clr [m].i clear bit of data memory 1 note none set [m].i set bit of data memory 1 note none branch jmp addr jump unconditionally 2 none sz [m] skip if data memory is zero 1 note none sza [m] skip if data memory is zero with data movement to acc 1 note none sz [m].i skip if bit i of data memory is zero 1 note none snz [m].i skip if bit i of data memory is not zero 1 note none siz [m] skip if increment data memory is zero 1 note none sdz [m] skip if decrement data memory is zero 1 note none siza [m] skip if increment data memory is zero with result in acc 1 note none sdza [m] skip if decrement data memory is zero with result in acc 1 note none call addr subroutine call 2 none ret return from subroutine 2 none ret a,x return from subroutine and load immediate data to acc 2 none reti return from interrupt 2 none table read tabrdc [m] (4) read rom code(locate by tblp and tbhp) to data memory and tblh 2 note none tabrdc [m] (5) read rom code(current page) to data memory and tblh 2 note none tabrdl [m] read table (last page) to tblh and data memory 2 note none miscellaneous nop no operation 1 none clr [m] clear data memory 1 note none set [m] set data memory 1 note none clr wdt clear watchdog timer 1 to, pdf clr wdt1 pre-clear watchdog timer 1 to, pdf clr wdt2 pre-clear watchdog timer 1 to, pdf swap [m] swap nibbles of data memory 1 note none swapa [m] swap nibbles of data memory with result in acc 1 none halt enter power down mode 1 to, pdf note: 1. for skip instructions, if the result of the comparison involves a skip then two cycles are required, if no skip takes place only one cycle is required. 2. any instruction which changes the contents of the pcl will also require 2 cycles for execution. 3. for the "clr wdt1" and "clr wdt2" instructions the to and pdf flags may be affected by the execution status. the to and pdf flags are cleared after both "clr wdt1" and "clr wdt2" instructions are consecutively executed. otherwise the to and pdf fags remain unchanged. 4. "tbhp option" is enabled by confguration option. 5. "tbhp option" is disabled by confguration option.
rev. 1.00 70 october 27, 2011 rev. 1.00 71 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface instruction defnition add data memory to acc with carry the contents of the specifed data memory, accumulator and the carry fag are added. the result is stored in the accumulator. acc acc + [m] + c ov, z, ac, c add acc to data memory with carry the contents of the specifed data memory, accumulator and the carry fag are added. the result is stored in the specifed data memory. [m] acc + [m] + c ov, z, ac, c add data memory to acc the contents of the specifed data memory and the accumulator are added. the result is stored in the accumulator. acc acc + [m] ov, z, ac, c add immediate data to acc the contents of the accumulator and the specifed immediate data are added. the result is stored in the accumulator. ac acc + x ov, z, ac, c add acc to data memory the contents of the specifed data memory and the accumulator are added. the result is stored in the specifed data memory. [m] acc + [m] ov, z, ac, c logical and data memory to acc data in the accumulator and the specifed data memory perform a bitwise logical and operation. the result is stored in the accumulator. acc acc and [m] z logical and immediate data to acc data in the accumulator and the specified immediate data perform a bitwise logical and operation. the result is stored in the accumulator. acc acc and x z logical and acc to data memory data in the specifed data memory and the accumulator perform a bitwise logical and operation. the result is stored in the data memory. [m] acc and [m] z adc a,[m] description operation affected fag(s) adcm a,[m] description operation affected fag(s) add a,[m] description operation affected fag(s) add a,x description operation affected fag(s) addm a,[m] description operation affected fag(s) and a,[m] description operation affected fag(s) and a,x description operation affected fag(s) andm a,[m] description operation affected fag(s)
rev. 1.00 72 october 27, 2011 rev. 1.00 73 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface subroutine call unconditionally calls a subroutine at the specifed address. the program counter then increments by 1 to obtain the address of the next instruction which is then pushed onto the stack. the specified address is then loaded and the program continues execution from this new address. as this instruction requires an additional operation, it is a two cycle instruction. stack program counter + 1 program counter addr none clear data memory each bit of the specifed data memory is cleared to 0. [m] 00h none clear bit of data memory bit i of the specifed data memory is cleared to 0. [m].i 0 none clear watchdog timer the to, pdf fags and the wdt are all cleared. wdt cleared to 0 pdf 0 to, pdf pre-clear watchdog timer the to, pdf fags and the wdtare all cleared. note that this instruction works in conjunction with clr wdt2 and must be executed alternately with clr wdt2 to have effect. repetitively executing this instruction without alternately executing clr wdt2 will have no effect. wdt cleared to 0 pdf 0 to, pdf pre-clear watchdog timer the to, pdf fags and the wdtare all cleared. note that this instruction works in conjunction with clr wdt1 and must be executed alternately with clr wdt1 to have effect. repetitively executing this instruction without alternately executing wdt cleared to 0 pdf 0 to, pdf call addr description operation affected fag(s) clr [m] description operation affected fag(s) clr [m].i description operation affected fag(s) clr wdt description operation affected fag(s) clr wdt1 description operation affected fag(s) clr wdt2 description operation affected fag(s)
rev. 1.00 72 october 27, 2011 rev. 1.00 73 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface complement data memory each bit of the specified data memory is logically complemented (1 ' s complement). bits which previously contained a 1 are changed to 0 and vice versa. [m] [m] z complement data memory with result in acc each bit of the specified data memory is logically complemented (1 ' s complement). bits which previously contained a 1 are changed to 0 and vice versa. the complemented result is stored in the accumulator and the contents of the data memory remain unchanged. acc [m] z decimal-adjust acc for addition with result in data memory convert the contents of the accumulator value to a bcd ( binary coded decimal) value resulting from the previous addition of two bcd variables. if the low nibble is greater than 9 or if ac fag is set, then a value of 6 will be added to the low nibble. otherwise the low nibble remains unchanged. if the high nibble is greater than 9 or if the c fag is set, then a value of 6 will be added to the high nibble. essentially, the decimal conversion is performed by adding 00h, 06h, 60h or 66h depending on the accumulator and fag conditions. only the c fag may be affected by this instruction which indicates that if the original bcd sum is greater than 100, it allows multiple precision decimal addition. [m] acc + 00h or [m] acc + 06h or [m] acc + 60h or [m] acc + 66h c decrement data memory data in the specifed data memory is decremented by 1. [m] [m] D 1 z decrement data memory with result in acc data in the specifed data memory is decremented by 1. the result is stored in the accumulator. the contents of the data memory remain unchanged. acc [m] D 1 z cpl [m] description operation affected fag(s) cpla [m] description operation affected fag(s) daa [m] description operation affected fag(s) dec [m] description operation affected fag(s) deca [m] description operation affected fag(s)
rev. 1.00 74 october 27, 2011 rev. 1.00 75 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface enter power down mode this instruction stops the program execution and turns off the system clock. the contents of the data memory and registers are retained. the wdt and prescaler are cleared. the power down flag pdf is set and the wdt time-out flag to is cleared. to 0 pdf 0 to, pdf increment data memory data in the specifed data memory is incremented by 1. [m] [m]+1 z increment data memory with result in acc data in the specifed data memory is incremented by 1. the result is stored in the accumulator. the contents of the data memory remain unchanged. acc [m]+1 z jump unconditionally the contents of the program counter are replaced with the specified address. program execution then continues from this new address. as this requires the insertion of a dummy instruction while the new address is loaded, it is a two cycle instruction. program counter addr none move data memory to acc the contents of the specifed data memory are copied to the accumulator. acc [m] none move immediate data to acc the immediate data specifed is loaded into the accumulator. acc x none move acc to data memory the contents of the accumulator are copied to the specifed data memory. [m] acc none no operation no operation is performed. execution continues with the next instruction. no operation none halt description operation affected fag(s) inc [m] description operation affected fag(s) inca [m] description operation affected fag(s) jmp addr description operation affected fag(s) mov a,[m] description operation affected fag(s) mov a,x description operation affected fag(s) mov [m],a description operation affected fag(s) nop description operation affected fag(s)
rev. 1.00 74 october 27, 2011 rev. 1.00 75 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface logical or data memory to acc data in the accumulator and the specifed data memory perform a bitwise logical or operation. the result is stored in the accumulator. acc acc " or " [m] z logical or immediate data to acc data in the accumulator and the specified immediate data perform a bitwise logical or operation. the result is stored in the accumulator. acc acc " or " x z logical or acc to data memory data in the specifed data memory and the accumulator perform a bitwise logical or operation. the result is stored in the data memory. [m] acc " or " [m] z return from subroutine the program counter is restored from the stack. program execution continues at the restored address. program counter stack none return from subroutine and load immediate data to acc the program counter is restored from the stack and the accumulator loaded with the specifed immediate data. program execution continues at the restored address. program counter stack acc x none return from interrupt the program counter is restored from the stack and the interrupts are re-enabled by setting the emi bit. emi is the master interrupt global enable bit. if an interrupt was pending when the reti instruction is executed, the pending interrupt routine will be processed before returning to the main program. program counter stack emi 1 none rotate data memory left the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. [m].(i+1) [m].i; (i = 0~6) [m].0 [m].7 none or a,[m] description operation affected fag(s) or a,x description operation affected fag(s) orm a,[m] description operation affected fag(s) ret description operation affected fag(s) ret a,x description operation affected fag(s) reti description operation affected fag(s) rl [m] description operation affected fag(s)
rev. 1.00 76 october 27, 2011 rev. 1.00 77 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface . rotate data memory left with result in acc the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. acc.(i+1) [m].i; (i = 0~6) acc.0 [m].7 none rotate data memory left through carry the contents of the specifed data memory and the carry fag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry fag is rotated into bit 0. [m].(i+1) [m].i; (i = 0~6) [m].0 c c [m].7 c rotate data memory left through carry with result in acc data in the specifed data memory and the carry fag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry fag is rotated into the bit 0. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. acc.(i+1) [m].i; (i = 0~6) acc.0 c c [m].7 c rotate data memory right the contents of the specifed data memory are rotated right by 1 bit with bit 0 rotated into bit 7. [m].i [m].(i+1); (i = 0~6) [m].7 [m].0 none rotate data memory right with result in acc data in the specifed data memory and the carry fag are rotated right by 1 bit with bit 0 rotated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. acc.i [m].(i+1); (i = 0~6) acc.7 [m].0 none rotate data memory right through carry the contents of the specifed data memory and the carry fag are rotated right by 1 bit. bit 0 replaces the carry bit and the original carry fag is rotated into bit 7. [m].i [m].(i+1); (i = 0~6) [m].7 c c [m].0 c rla [m] description operation affected fag(s) rlc [m] description operation affected fag(s) rlca [m] description operation affected fag(s) rr [m] description operation affected fag(s) rra [m] description operation affected fag(s) rrc [m] description operation affected fag(s)
rev. 1.00 76 october 27, 2011 rev. 1.00 77 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface rotate data memory right through carry with result in acc data in the specifed data memory and the carry fag are rotated right by 1 bit. bit 0 replaces the carry bit and the original carry fag is rotated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. acc.i [m].(i+1); (i = 0~6) acc.7 c c [m].0 c subtract data memory from acc with carry the contents of the specifed data memory and the complement of the carry fag are subtracted from the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. acc acc D [m] D c ov, z, ac, c subtract data memory from acc with carry and result in data memory the contents of the specifed data memory and the complement of the carry fag are subtracted from the accumulator. the result is stored in the data memory. note that if the result of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. acc acc D [m] D c ov, z, ac, c skip if decrement data memory is 0 the contents of the specifed data memory are frst decremented by 1. if the result is 0 the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. [m] [m] D 1 skip if [m] = 0 none skip if decrement data memory is zero with result in acc the contents of the specifed data memory are frst decremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the specifed data memory contents remain unchanged. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. acc [m] D 1 skip if acc = 0 none rrca [m] description operation affected fag(s) sbc a,[m] description operation affected fag(s) sbcm a,[m] description operation affected fag(s) sdz [m] description operation affected fag(s) sdza [m] description operation affected fag(s)
rev. 1.00 78 october 27, 2011 rev. 1.00 79 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface set data memory each bit of the specifed data memory is set to 1. [m] ffh none set bit of data memory bit i of the specifed data memory is set to 1. [m].1 1 none skip if increment data memory is 0 the contents of the specifed data memory are frst incremented by 1. if the result is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. [m] [m] + 1 skip if [m] = 0 none skip if increment data memory is zero with result in acc the contents of the specifed data memory are frst incremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the specifed data memory contents remain unchanged. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. acc [m] + 1 skip if acc = 0 none skip if bit i of data memory is not 0 if bit i of the specifed data memory is not 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is 0 the program proceeds with the following instruction. skip if [m].i 0 none subtract data memory from acc the specifed data memory is subtracted from the contents of the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. acc acc D [m] ov, z, ac, c set [m] description operation affected fag(s) set [m].i description operation affected fag(s) siz [m] description operation affected fag(s) siza [m] description operation affected fag(s) snz [m].i description operation affected fag(s) sub a,[m] description operation affected fag(s)
rev. 1.00 78 october 27, 2011 rev. 1.00 79 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface subtract data memory from acc with result in data memory the specifed data memory is subtracted from the contents of the accumulator. the result is stored in the data memory. note that if the result of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. [m] acc D [m] ov, z, ac, c subtract immediate data from acc the immediate data specifed by the code is subtracted from the contents of the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. acc acc D x ov, z, ac, c swap nibbles of data memory the low-order and high-order nibbles of the specified data memory are interchanged. [m].3~[m].0?[m].7 ~ [m].4 none swap nibbles of data memory with result in acc the low-order and high-order nibbles of the specified data memory are interchanged. the result is stored in the accumulator. the contents of the data memory remain unchanged. acc.3 ~ acc.0 [m].7 ~ [m].4 acc.7 ~ acc.4 [m].3 ~ [m].0 none skip if data memory is 0 if the contents of the specified data memory is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. skip if [m] = 0 none skip if data memory is 0 with data movement to acc the contents of the specifed data memory are copied to the accumulator. if the value is zero, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. acc [m] skip if [m] = 0 none subm a,[m] description operation affected fag(s) sub a,x description operation affected fag(s) swap [m] description operation affected fag(s) swapa [m] description operation affected fag(s) sz [m] description operation affected fag(s) sza [m] description operation affected fag(s)
rev. 1.00 80 october 27, 2011 rev. 1.00 81 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface skip if bit i of data memory is 0 if bit i of the specifed data memory is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. skip if [m].i = 0 none read table (current page) to tblh and data memory the low byte of the program code (current page) addressed by the table pointer (tblp) is moved to the specifed data memory and the high byte moved to tblh. [m] program code (low byte) tblh program code (high byte) none move the rom code (locate by tblp and tbhp) to tblh and data memory (rom code tbhp is enabled) the low byte of rom code addressed by the table pointers (tblp and tbhp) is moved to the specified data memory and the high byte transferred to tblh directly. [m] program code (low byte) tblh program code (high byte) none read table (last page) to tblh and data memory the low byte of the program code (last page) addressed by the table pointer (tblp) is moved to the specifed data memory and the high byte moved to tblh. [m] program code (low byte) tblh program code (high byte) none logical xor data memory to acc data in the accumulator and the specifed data memory perform a bitwise logical xor operation. the result is stored in the accumulator. acc acc " xor " [m] z logical xor acc to data memory data in the specifed data memory and the accumulator perform a bitwise logical xor operation. the result is stored in the data memory. [m] acc " xor " [m] z logical xor immediate data to acc data in the accumulator and the specified immediate data perform a bitwise logical xor operation. the result is stored in the accumulator. acc acc " xor " x z sz [m].i description operation affected fag(s) tabrdc [m] description operation affected fag(s) tabrdc [m] description operation affected fag(s) tabrdl [m] description operation affected fag(s) xor a,[m] description operation affected fag(s) xorm a,[m] description operation affected fag(s) xor a,x description operation affected fag(s)
rev. 1.00 80 october 27, 2011 rev. 1.00 81 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface package information note that the package information provided here is for consultation purposes only. as this information may be updated at regular intervals users are reminded to consult the holtek website (http://www.holtek.com.tw/english/literature/package.pdf) for the latest version of the package information. 16-pin nsop (150mil) outline dimensions               ms-012 symbol dimensions in inch min. nom. max. a 0.228 D 0.244 b 0.150 D 0.157 c 0.012 D 0.020 c ? 0.386 D 0.402 d D D 0.069 e D 0.050 D f 0.004 D 0.010 g 0.016 D 0.050 h 0.007 D 0.010 0 D 8 symbol dimensions in mm min. nom. max. a 5.79 D 6.20 b 3.81 D 3.99 c 0.30 D 0.51 c ? 9.80 D 10.21 d D D 1.75 e D 1.27 D f 0.10 D 0.25 g 0.41 D 1.27 h 0.18 D 0.25 0 D 8
rev. 1.00 82 october 27, 2011 rev. 1.00 83 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface 20-pin ssop (150mil) outline dimensions              symbol dimensions in inch min. nom. max. a 0.228 D 0.244 b 0.150 D 0.158 c 0.008 D 0.012 c ? 0.335 D 0.347 d 0.049 D 0.065 e D 0.025 D f 0.004 D 0.010 g 0.015 D 0.050 h 0.007 D 0.010 0 D 8 symbol dimensions in mm min. nom. max. a 5.79 D 6.20 b 3.81 D 4.01 c 0.20 D 0.30 c ? 8.51 D 8.81 d 1.24 D 1.65 e D 0.64 D f 0.10 D 0.25 g 0.38 D 1.27 h 0.18 D 0.25 0 D 8
rev. 1.00 82 october 27, 2011 rev. 1.00 83 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface saw type 20-pin (4mm4mm) qfn outline dimensions                    gtk symbol dimensions in inch min. nom. max. a 0.031 D 0.035 a1 0.000 0.001 0.002 a3 D 0.008 D b 0.007 0.010 0.012 d D 0.157 D e D 0.157 D e D 0.020 D d2 0.075 D 0.081 e2 0.075 D 0.081 l 0.012 0.016 0.020 k 0.008 D D symbol dimensions in mm min. nom. max. a 0.80 D 0.90 a1 0.00 0.02 0.05 a3 D 0.203 D b 0.18 0.25 0.30 d D 4.00 D e D 4.00 D e D 0.50 D d2 1.90 2.00 2.05 e2 1.90 2.00 2.05 l 0.30 0.40 0.50 k 0.20 D D
rev. 1.00 84 october 27, 2011 rev. 1.00 85 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface reel dimensions       16-pin nsop(150mil) symbol description dimensions in mm a reel outer diameter 330.01.0 b reel inner diameter 100.01.5 c spindle hole diameter 13.0 +0.5/-0.2 d key slit width 2.00.5 t1 space between flang 16.8 +0.3/-0.2 t2 reel thickness 22.20.2 ssop 20s (150mil) symbol description dimensions in mm a reel outer diameter 330.01.0 b reel inner diameter 100.01.5 c spindle hole diameter 13.0 +0.5/-0.2 d key slit width 2.00.5 t1 space between flang 16.8 +0.3/-0.2 t2 reel thickness 22.20.2
rev. 1.00 84 october 27, 2011 rev. 1.00 85 october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface carrier tape dimensions                   
  
               
          16-pin nsop (150mil) symbol description dimensions in mm w carrier tape width 16.00.3 p cavity pitch 8.00.1 e perforation position 1.750.1 f cavity to perforation(width direction) 7.50.1 d perforation diameter 1.55 +0.10/-0.00 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation(length direction) 2.00.1 a0 cavity length 6.50.1 b0 cavity width 10.30.1 k0 cavity depth 2.10.1 t carrier tape thickness 0.300.05 c cover tape width 13.30.1 ssop 20s (150mil) symbol description dimensions in mm w carrier tape width 16.0 +0.3/-0.1 p cavity pitch 8.00.1 e perforation position 1.750.10 f cavity to perforation(width direction) 7.50.1 d perforation diameter 1.5 +0.1/-0.0 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation(length direction) 2.00.1 a0 cavity length 6.50.1 b0 cavity width 9.00.1 k0 cavity depth 2.30.1 t carrier tape thickness 0.300.05 c cover tape width 13.30.1
rev. 1.00 86 october 27, 2011 rev. 1.00 pb october 27, 2011 HT82B42R/HT82B42Re i/o mcu with usb interface holtek semiconductor inc. (headquarters) no.3, creation rd. ii, science park, hsinchu, taiwan tel: 886-3-563-1999 fax: 886-3-563-1189 http://www.holtek.com.tw holtek semiconductor inc. (taipei sales offce) 4f-2, no. 3-2, yuanqu st., nankang software park, taipei 115, taiwan tel: 886-2-2655-7070 fax: 886-2-2655-7373 fax: 886-2-2655-7383 (international sales hotline) holtek semiconductor inc. (shenzhen sales offce) 5f, unit a, productivity building, no.5 gaoxin m 2nd road, nanshan district, shenzhen, china 518057 tel: 86-755-8616-9908, 86-755-8616-9308 fax: 86-755-8616-9722 holtek semiconductor (usa), inc. (north america sales offce) 46729 fremont blvd., fremont, ca 94538, usa tel: 1-510-252-9880 fax: 1-510-252-9885 http://www.holtek.com copyright ? 2011 by holtek semiconductor inc. the information appearing in this data sheet is believed to be accurate at the time of publication. however, holtek assumes no responsibility arising from the use of the specifications described. the applications mentioned herein are used solely for the purpose of illustration and holtek makes no warranty or representation that such applications will be suitable without further modifcation, nor recommends the use of its products for application that may present a risk to human life due to malfunction or otherwise. holtek's products are not authorized for use as critical components in life support devices or systems. holtek reserves the right to alter its products without prior notifcation. for the most up-to-date information, please visit our web site at http://www.holtek.com.tw .


▲Up To Search▲   

 
Price & Availability of HT82B42R

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X